static void gail_scale_get_character_extents (AtkText *text, gint offset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coords) { GtkWidget *widget; GtkScale *scale; PangoRectangle char_rect; PangoLayout *layout; gint index, x_layout, y_layout; const gchar *scale_text; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) /* State is defunct */ return; scale = GTK_SCALE (widget); layout = gtk_scale_get_layout (scale); if (!layout) return; scale_text = pango_layout_get_text (layout); if (!scale_text) return; index = g_utf8_offset_to_pointer (scale_text, offset) - scale_text; gtk_scale_get_layout_offsets (scale, &x_layout, &y_layout); pango_layout_index_to_pos (layout, index, &char_rect); gail_misc_get_extents_from_pango_rectangle (widget, &char_rect, x_layout, y_layout, x, y, width, height, coords); }
static gunichar gail_scale_get_character_at_offset (AtkText *text, gint offset) { GtkWidget *widget; GtkScale *scale; PangoLayout *layout; const gchar *string; gchar *index; gunichar c; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) /* State is defunct */ return '\0'; scale = GTK_SCALE (widget); layout = gtk_scale_get_layout (scale); if (!layout) return '\0'; string = pango_layout_get_text (layout); if (offset >= g_utf8_strlen (string, -1)) c = '\0'; else { index = g_utf8_offset_to_pointer (string, offset); c = g_utf8_get_char (index); } return c; }
static gchar* gail_scale_get_text_after_offset (AtkText *text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset) { GtkWidget *widget; GailScale *scale; PangoLayout *layout; gchar *txt; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) /* State is defunct */ return NULL; scale = GAIL_SCALE (text); layout = gtk_scale_get_layout (GTK_SCALE (widget)); if (layout) { txt = gail_text_util_get_text (scale->textutil, layout, GAIL_AFTER_OFFSET, boundary_type, offset, start_offset, end_offset); } else txt = NULL; return txt; }
static void gail_scale_notify (GObject *obj, GParamSpec *pspec) { GailScale *scale = GAIL_SCALE (obj); if (strcmp (pspec->name, "accessible-value") == 0) { GtkWidget *widget; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); if (widget) { GtkScale *gtk_scale; PangoLayout *layout; const gchar *txt; gtk_scale = GTK_SCALE (widget); layout = gtk_scale_get_layout (gtk_scale); if (layout) { txt = pango_layout_get_text (layout); if (txt) { g_signal_emit_by_name (obj, "text_changed::delete", 0, gtk_text_buffer_get_char_count (scale->textutil->buffer)); gail_text_util_text_setup (scale->textutil, txt); g_signal_emit_by_name (obj, "text_changed::insert", 0, g_utf8_strlen (txt, -1)); } } } } G_OBJECT_CLASS (gail_scale_parent_class)->notify (obj, pspec); }
static const gchar * gtk_scale_accessible_get_description (AtkObject *object) { GtkWidget *widget; PangoLayout *layout; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (object)); if (widget == NULL) return NULL; layout = gtk_scale_get_layout (GTK_SCALE (widget)); if (layout) return pango_layout_get_text (layout); return ATK_OBJECT_CLASS (_gtk_scale_accessible_parent_class)->get_description (object); }
static AtkAttributeSet* gail_scale_get_run_attributes (AtkText *text, gint offset, gint *start_offset, gint *end_offset) { GtkWidget *widget; GtkScale *scale; AtkAttributeSet *at_set = NULL; GtkTextDirection dir; PangoLayout *layout; const gchar *scale_text; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) /* State is defunct */ return NULL; scale = GTK_SCALE (widget); layout = gtk_scale_get_layout (scale); if (!layout) return at_set; scale_text = pango_layout_get_text (layout); if (!scale_text) return at_set; dir = gtk_widget_get_direction (widget); 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, layout, (gchar *)scale_text, offset, start_offset, end_offset); return at_set; }
static AtkAttributeSet* gail_scale_get_default_attributes (AtkText *text) { GtkWidget *widget; AtkAttributeSet *at_set = NULL; PangoLayout *layout; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) /* State is defunct */ return NULL; layout = gtk_scale_get_layout (GTK_SCALE (widget)); if (layout) { at_set = gail_misc_get_default_attributes (at_set, layout, widget); } return at_set; }
static gint gail_scale_get_offset_at_point (AtkText *text, gint x, gint y, AtkCoordType coords) { GtkWidget *widget; GtkScale *scale; PangoLayout *layout; gint index, x_layout, y_layout; const gchar *scale_text; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text)); if (widget == NULL) /* State is defunct */ return -1; scale = GTK_SCALE (widget); layout = gtk_scale_get_layout (scale); if (!layout) return -1; scale_text = pango_layout_get_text (layout); if (!scale_text) return -1; gtk_scale_get_layout_offsets (scale, &x_layout, &y_layout); index = gail_misc_get_index_at_point_in_layout (widget, layout, x_layout, y_layout, x, y, coords); if (index == -1) { if (coords == ATK_XY_WINDOW || coords == ATK_XY_SCREEN) index = g_utf8_strlen (scale_text, -1); } else index = g_utf8_pointer_to_offset (scale_text, scale_text + index); return index; }
static void gail_scale_real_initialize (AtkObject *obj, gpointer data) { GailScale *gail_scale; const gchar *txt; PangoLayout *layout; ATK_OBJECT_CLASS (gail_scale_parent_class)->initialize (obj, data); gail_scale = GAIL_SCALE (obj); gail_scale->textutil = gail_text_util_new (); layout = gtk_scale_get_layout (GTK_SCALE (data)); if (layout) { txt = pango_layout_get_text (layout); if (txt) { gail_text_util_text_setup (gail_scale->textutil, txt); } } }