a11y: Solved leak on gtk_widget_accessible_get_description

https://bugzilla.gnome.org/show_bug.cgi?id=643611
This commit is contained in:
Alejandro Piñeiro 2012-09-11 21:17:22 +02:00
parent 634ebb593c
commit 5ff328d21f

View File

@ -24,6 +24,8 @@
#include "gtkwidgetaccessible.h"
#include "gtknotebookpageaccessible.h"
#define TOOLTIP_KEY "tooltip"
extern GtkWidget *_focus_widget;
@ -106,6 +108,16 @@ gtk_widget_accessible_focus_event (AtkObject *obj,
atk_object_notify_state_change (focus_obj, ATK_STATE_FOCUSED, focus_in);
}
static void
gtk_widget_accessible_update_tooltip (GtkWidgetAccessible *accessible,
GtkWidget *widget)
{
g_object_set_data_full (G_OBJECT (accessible),
TOOLTIP_KEY,
gtk_widget_get_tooltip_text (widget),
g_free);
}
static void
gtk_widget_accessible_initialize (AtkObject *obj,
gpointer data)
@ -123,6 +135,8 @@ gtk_widget_accessible_initialize (AtkObject *obj,
GTK_WIDGET_ACCESSIBLE (obj)->layer = ATK_LAYER_WIDGET;
obj->role = ATK_ROLE_UNKNOWN;
gtk_widget_accessible_update_tooltip (GTK_WIDGET_ACCESSIBLE (obj), widget);
}
static const gchar *
@ -137,7 +151,7 @@ gtk_widget_accessible_get_description (AtkObject *accessible)
if (accessible->description)
return accessible->description;
return gtk_widget_get_tooltip_text (widget);
return g_object_get_data (G_OBJECT (accessible), TOOLTIP_KEY);
}
static AtkObject *
@ -475,7 +489,11 @@ gtk_widget_accessible_notify_gtk (GObject *obj,
state = ATK_STATE_HORIZONTAL;
value = (gtk_orientable_get_orientation (orientable) == GTK_ORIENTATION_HORIZONTAL);
}
else
else if (g_strcmp0 (pspec->name, "tooltip-text") == 0)
{
gtk_widget_accessible_update_tooltip (GTK_WIDGET_ACCESSIBLE (atk_obj),
widget);
}
return;
atk_object_notify_state_change (atk_obj, state, value);