static gchar* gail_expander_get_text (AtkText *text, gint start_pos, gint end_pos) { GtkWidget *widget; GailExpander *expander; const gchar *label_text; widget = GTK_ACCESSIBLE (text)->widget; if (widget == NULL) /* State is defunct */ return NULL; expander = GAIL_EXPANDER (text); if (!expander->textutil) gail_expander_init_textutil (expander, GTK_EXPANDER (widget)); label_text = gail_expander_get_full_text (GTK_EXPANDER (widget)); if (label_text == NULL) return NULL; else return gail_text_util_get_substring (expander->textutil, start_pos, end_pos); }
static gchar* gail_expander_get_text_after_offset (AtkText *text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset) { GtkWidget *widget; GailExpander *expander; GtkWidget *label; widget = GTK_ACCESSIBLE (text)->widget; if (widget == NULL) /* State is defunct */ return NULL; expander = GAIL_EXPANDER (text); if (!expander->textutil) gail_expander_init_textutil (expander, GTK_EXPANDER (widget)); label = gtk_expander_get_label_widget (GTK_EXPANDER (widget)); if (!GTK_IS_LABEL(label)) return NULL; return gail_text_util_get_text (expander->textutil, gtk_label_get_layout (GTK_LABEL (label)), GAIL_AFTER_OFFSET, boundary_type, offset, start_offset, end_offset); }
static gboolean gail_expander_do_action (AtkAction *action, gint i) { GtkWidget *widget; GailExpander *expander; gboolean return_value = TRUE; widget = GTK_ACCESSIBLE (action)->widget; if (widget == NULL) /* * State is defunct */ return FALSE; if (!GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget)) return FALSE; expander = GAIL_EXPANDER (action); switch (i) { case 0: if (expander->action_idle_handler) return_value = FALSE; else expander->action_idle_handler = gdk_threads_add_idle (idle_do_action, expander); break; default: return_value = FALSE; break; } return return_value; }
static gboolean gail_expander_set_description (AtkAction *action, gint i, const gchar *desc) { GailExpander *expander; gchar **value; expander = GAIL_EXPANDER (action); switch (i) { case 0: value = &expander->activate_description; break; default: value = NULL; break; } if (value) { g_free (*value); *value = g_strdup (desc); return TRUE; } else return FALSE; }
static gboolean idle_do_action (gpointer data) { GtkWidget *widget; GailExpander *gail_expander; GDK_THREADS_ENTER (); gail_expander = GAIL_EXPANDER (data); gail_expander->action_idle_handler = 0; widget = GTK_ACCESSIBLE (gail_expander)->widget; if (widget == NULL /* State is defunct */ || !GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget)) { GDK_THREADS_LEAVE (); return FALSE; } gtk_widget_activate (widget); GDK_THREADS_LEAVE (); return FALSE; }
static void gail_expander_map_gtk (GtkWidget *widget, gpointer data) { GailExpander *expander; expander = GAIL_EXPANDER (data); gail_expander_init_textutil (expander, GTK_EXPANDER (widget)); }
static void gail_expander_finalize (GObject *object) { GailExpander *expander = GAIL_EXPANDER (object); g_free (expander->activate_description); g_free (expander->activate_keybinding); if (expander->action_idle_handler) { g_source_remove (expander->action_idle_handler); expander->action_idle_handler = 0; } if (expander->textutil) g_object_unref (expander->textutil); G_OBJECT_CLASS (gail_expander_parent_class)->finalize (object); }
static G_CONST_RETURN gchar* gail_expander_get_keybinding (AtkAction *action, gint i) { GailExpander *expander; gchar *return_value = NULL; switch (i) { case 0: { /* * We look for a mnemonic on the label */ GtkWidget *widget; GtkWidget *label; expander = GAIL_EXPANDER (action); widget = GTK_ACCESSIBLE (expander)->widget; if (widget == NULL) /* * State is defunct */ return NULL; g_return_val_if_fail (GTK_IS_EXPANDER (widget), NULL); label = gtk_expander_get_label_widget (GTK_EXPANDER (widget)); if (GTK_IS_LABEL (label)) { guint key_val; key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label)); if (key_val != GDK_VoidSymbol) return_value = gtk_accelerator_name (key_val, GDK_MOD1_MASK); g_free (expander->activate_keybinding); expander->activate_keybinding = return_value; } break; } default: break; } return return_value; }
static void gail_expander_real_notify_gtk (GObject *obj, GParamSpec *pspec) { AtkObject* atk_obj; GtkExpander *expander; GailExpander *gail_expander; expander = GTK_EXPANDER (obj); atk_obj = gtk_widget_get_accessible (GTK_WIDGET (expander)); ; if (strcmp (pspec->name, "label") == 0) { const gchar* label_text; label_text = gail_expander_get_full_text (expander); gail_expander = GAIL_EXPANDER (atk_obj); if (gail_expander->textutil) gail_text_util_text_setup (gail_expander->textutil, label_text); if (atk_obj->name == NULL) { /* * The label has changed so notify a change in accessible-name */ g_object_notify (G_OBJECT (atk_obj), "accessible-name"); } /* * The label is the only property which can be changed */ g_signal_emit_by_name (atk_obj, "visible_data_changed"); } else if (strcmp (pspec->name, "expanded") == 0) { atk_object_notify_state_change (atk_obj, ATK_STATE_CHECKED, gtk_expander_get_expanded (expander)); atk_object_notify_state_change (atk_obj, ATK_STATE_EXPANDED, gtk_expander_get_expanded (expander)); g_signal_emit_by_name (atk_obj, "visible_data_changed"); } else GAIL_WIDGET_CLASS (gail_expander_parent_class)->notify_gtk (obj, pspec); }
static gboolean idle_do_action (gpointer data) { GtkWidget *widget; GailExpander *gail_expander; gail_expander = GAIL_EXPANDER (data); gail_expander->action_idle_handler = 0; widget = GTK_ACCESSIBLE (gail_expander)->widget; if (widget == NULL /* State is defunct */ || !gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget)) return FALSE; gtk_widget_activate (widget); return FALSE; }
static G_CONST_RETURN gchar* gail_expander_get_description (AtkAction *action, gint i) { GailExpander *expander; G_CONST_RETURN gchar *return_value; expander = GAIL_EXPANDER (action); switch (i) { case 0: return_value = expander->activate_description; break; default: return_value = NULL; break; } return return_value; }
static void gail_expander_real_initialize (AtkObject *obj, gpointer data) { GailExpander *gail_expander = GAIL_EXPANDER (obj); GtkWidget *expander; ATK_OBJECT_CLASS (gail_expander_parent_class)->initialize (obj, data); expander = GTK_WIDGET (data); if (GTK_WIDGET_MAPPED (expander)) gail_expander_init_textutil (gail_expander, GTK_EXPANDER (expander)); else g_signal_connect (expander, "map", G_CALLBACK (gail_expander_map_gtk), gail_expander); obj->role = ATK_ROLE_TOGGLE_BUTTON; }