예제 #1
0
파일: gailbutton.c 프로젝트: BYC/gtk
static void
gail_button_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_button (widget, 0, FALSE);

  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);
} 
예제 #2
0
파일: gailbutton.c 프로젝트: BYC/gtk
static gunichar 
gail_button_get_character_at_offset (AtkText	         *text,
                                     gint	         offset)
{
  GtkWidget *widget;
  GtkWidget *label;
  const gchar *string;
  gchar *index;

  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));

  if (widget == NULL)
    /* State is defunct */
    return '\0';

  label = get_label_from_button (widget, 0, FALSE);

  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);
}
예제 #3
0
파일: gailbutton.c 프로젝트: BYC/gtk
static gchar*
gail_button_get_text_after_offset (AtkText         *text,
				   gint            offset,
				   AtkTextBoundary boundary_type,
				   gint            *start_offset,
				   gint            *end_offset)
{
  GtkWidget *widget;
  GtkWidget *label;
  GailButton *button;

  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));

  if (widget == NULL)
  {
    /* State is defunct */
    return NULL;
  }
  
  /* Get label */
  label = get_label_from_button (widget, 0, FALSE);

  if (!GTK_IS_LABEL(label))
    return NULL;

  button = GAIL_BUTTON (text);
  if (!button->textutil)
    gail_button_init_textutil (button, label);

  return gail_text_util_get_text (button->textutil,
                           gtk_label_get_layout (GTK_LABEL (label)), GAIL_AFTER_OFFSET, 
                           boundary_type, offset, start_offset, end_offset);
}
예제 #4
0
파일: gailbutton.c 프로젝트: BYC/gtk
static gchar*
gail_button_get_text (AtkText *text,
                      gint    start_pos,
                      gint    end_pos)
{
  GtkWidget *widget;
  GtkWidget  *label;
  GailButton *button;
  const gchar *label_text;

  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));

  if (widget == NULL)
    /* State is defunct */
    return NULL;

  label = get_label_from_button (widget, 0, FALSE);

  if (!GTK_IS_LABEL (label))
    return NULL;

  button = GAIL_BUTTON (text);
  if (!button->textutil) 
    gail_button_init_textutil (button, label);

  label_text = gtk_label_get_text (GTK_LABEL (label));

  if (label_text == NULL)
    return NULL;
  else
  {
    return gail_text_util_get_substring (button->textutil, 
                                         start_pos, end_pos);
  }
}
예제 #5
0
static const gchar *
gtk_button_accessible_get_name (AtkObject *obj)
{
  const gchar *name = NULL;
  GtkWidget *widget;
  GtkWidget *child;

  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
  if (widget == NULL)
    return NULL;

  name = ATK_OBJECT_CLASS (gtk_button_accessible_parent_class)->get_name (obj);
  if (name != NULL)
    return name;

  child = get_label_from_button (widget);
  if (GTK_IS_LABEL (child))
    name = gtk_label_get_text (GTK_LABEL (child));
  else
    {
      GtkWidget *image;

      image = get_image_from_button (widget);
      if (GTK_IS_IMAGE (image))
        {
          AtkObject *atk_obj;

          atk_obj = gtk_widget_get_accessible (image);
          name = atk_object_get_name (atk_obj);
        }
    }

  return name;
}
예제 #6
0
파일: gailbutton.c 프로젝트: BYC/gtk
static AtkAttributeSet*
gail_button_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_button (widget, 0, FALSE);

  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;
}
예제 #7
0
파일: gailbutton.c 프로젝트: BYC/gtk
static void
gail_button_real_initialize (AtkObject *obj,
                             gpointer   data)
{
  GailButton *button = GAIL_BUTTON (obj);
  GtkWidget  *label;
  GtkWidget  *widget;

  ATK_OBJECT_CLASS (gail_button_parent_class)->initialize (obj, data);

  button->state = GTK_STATE_NORMAL;

  g_signal_connect (data,
                    "pressed",
                    G_CALLBACK (gail_button_pressed_enter_handler),
                    NULL);
  g_signal_connect (data,
                    "enter",
                    G_CALLBACK (gail_button_pressed_enter_handler),
                    NULL);
  g_signal_connect (data,
                    "released",
                    G_CALLBACK (gail_button_released_leave_handler),
                    NULL);
  g_signal_connect (data,
                    "leave",
                    G_CALLBACK (gail_button_released_leave_handler),
                    NULL);


  widget = GTK_WIDGET (data);
  label = get_label_from_button (widget, 0, FALSE);
  if (GTK_IS_LABEL (label))
    {
      if (gtk_widget_get_mapped (label))
        gail_button_init_textutil (button, label);
      else 
        g_signal_connect (label,
                          "map",
                          G_CALLBACK (gail_button_label_map_gtk),
                          button);
    }
  button->default_is_press = gail_button_is_default_press (widget);
    
  set_role_for_button (obj, data);
}
예제 #8
0
파일: gailbutton.c 프로젝트: BYC/gtk
static AtkObject*
gail_button_ref_child (AtkObject *obj,
                       gint      i)
{
  GtkWidget *widget;
  GtkWidget *child_widget;
  AtkObject *child;

  g_return_val_if_fail (GAIL_IS_BUTTON (obj), NULL);

  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
  if (widget == NULL)
    /*
     * State is defunct
     */
    return NULL;

  if (i >= gail_button_get_n_children (obj))
    return NULL;

  if (get_n_attached_menus (widget) > 0)
  {
    child_widget = get_nth_attached_menu (widget, i);
  }
  else
    child_widget = NULL;    

  if (!child_widget) 
    {
      if (get_n_labels_from_button (widget) > 1)
        {
          child_widget = get_label_from_button (widget, i, TRUE);
        }
    }

  if (child_widget)
    {
      child = gtk_widget_get_accessible (child_widget);
      g_object_ref (child);
    }
  else
    child = NULL;

  return child;
}
예제 #9
0
파일: gailbutton.c 프로젝트: BYC/gtk
static G_CONST_RETURN gchar*
gail_button_get_name (AtkObject *obj)
{
  G_CONST_RETURN gchar* name = NULL;

  g_return_val_if_fail (GAIL_IS_BUTTON (obj), NULL);

  name = ATK_OBJECT_CLASS (gail_button_parent_class)->get_name (obj);
  if (name == NULL)
    {
      /*
       * Get the text on the label
       */
      GtkWidget *widget;
      GtkWidget *child;

      widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
      if (widget == NULL)
        /*
         * State is defunct
         */
        return NULL;

      g_return_val_if_fail (GTK_IS_BUTTON (widget), NULL);

      child = get_label_from_button (widget, 0, FALSE);
      if (GTK_IS_LABEL (child))
        name = gtk_label_get_text (GTK_LABEL (child)); 
      else
        {
          GtkImage *image;

          image = get_image_from_button (widget);
          if (GTK_IS_IMAGE (image))
            {
              AtkObject *atk_obj;

              atk_obj = gtk_widget_get_accessible (GTK_WIDGET (image));
              name = atk_object_get_name (atk_obj);
            }
        }
    }
  return name;
}
예제 #10
0
파일: gailbutton.c 프로젝트: BYC/gtk
static gint
gail_button_get_character_count (AtkText *text)
{
  GtkWidget *widget;
  GtkWidget *label;

  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));

  if (widget == NULL)
    /* State is defunct */
    return 0;

  label = get_label_from_button (widget, 0, FALSE);

  if (!GTK_IS_LABEL(label))
    return 0;

  return g_utf8_strlen (gtk_label_get_text (GTK_LABEL (label)), -1);
}
예제 #11
0
파일: gailbutton.c 프로젝트: BYC/gtk
static gint 
gail_button_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_button (widget, 0, FALSE);

  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);  
}
예제 #12
0
파일: gailbutton.c 프로젝트: BYC/gtk
static AtkAttributeSet*
gail_button_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_button (widget, 0, FALSE);

  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;
}
예제 #13
0
파일: gailbutton.c 프로젝트: BYC/gtk
static G_CONST_RETURN gchar*
gail_button_get_keybinding (AtkAction *action,
                            gint      i)
{
  GailButton *button;
  gchar *return_value = NULL;

  button = GAIL_BUTTON (action);
  if (button->default_is_press)
    {
      if (i == 0)
        i = 1;
      else if (i == 1)
        i = 0;
    }
  switch (i)
    {
    case 0:
      {
        /*
         * We look for a mnemonic on the label
         */
        GtkWidget *widget;
        GtkWidget *label;
        guint key_val; 

        widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (button));
        if (widget == NULL)
          /*
           * State is defunct
           */
          return NULL;

        g_return_val_if_fail (GTK_IS_BUTTON (widget), NULL);

        label = get_label_from_button (widget, 0, FALSE);
        if (GTK_IS_LABEL (label))
          {
            key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label)); 
            if (key_val != GDK_KEY_VoidSymbol)
              return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK);
          }
        if (return_value == NULL)
          {
            /* Find labelled-by relation */
            AtkRelationSet *set;
            AtkRelation *relation;
            GPtrArray *target;
            gpointer target_object;

            set = atk_object_ref_relation_set (ATK_OBJECT (action));
            if (set)
              {
                relation = atk_relation_set_get_relation_by_type (set, ATK_RELATION_LABELLED_BY);
                if (relation)
                  {              
                    target = atk_relation_get_target (relation);
            
                    target_object = g_ptr_array_index (target, 0);
                    label = gtk_accessible_get_widget (GTK_ACCESSIBLE (target_object));
                  }
                g_object_unref (set);
              }

            if (GTK_IS_LABEL (label))
              {
                key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label)); 
                if (key_val != GDK_KEY_VoidSymbol)
                  return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK);
              }
          }
        g_free (button->click_keybinding);
        button->click_keybinding = return_value;
        break;
      }
    default:
      break;
    }
  return return_value; 
}