Merge lp:~apinheiro/unity/Bug817477 into lp:unity

Proposed by Alejandro Piñeiro
Status: Merged
Merged at revision: 1493
Proposed branch: lp:~apinheiro/unity/Bug817477
Merge into: lp:unity
Diff against target: 103 lines (+46/-12)
2 files modified
services/panel-indicator-accessible.c (+40/-10)
services/panel-indicator-entry-accessible.c (+6/-2)
To merge this branch: bzr merge lp:~apinheiro/unity/Bug817477
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Alex Launi Pending
Review via email: mp+73835@code.launchpad.net

Description of the change

In the end the solution was one line. panel_indicator_entry_accessible_ref_child is a implementation of atk_object_ref_child, and as the name implies, it supposes that a reference count is required.

This branch also some NULL check conditions that I started to add while triagging the bug. It is really tied to this and I really think that doesn't hurt. Anyway if you prefer just add that g_object_ref I'm ok to add a new bug

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Looks good to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'services/panel-indicator-accessible.c'
2--- services/panel-indicator-accessible.c 2011-03-15 10:57:34 +0000
3+++ services/panel-indicator-accessible.c 2011-09-02 15:02:24 +0000
4@@ -93,21 +93,51 @@
5 {
6 GSList *l;
7 PanelIndicatorAccessible *pia = PANEL_INDICATOR_ACCESSIBLE (user_data);
8+ gboolean found = FALSE;
9+ AtkObject *entry_accessible = NULL;
10+ AtkObject *widget_accessible = NULL;
11
12 for (l = pia->priv->a11y_children; l != NULL; l = l->next)
13 {
14- AtkObject *accessible = ATK_OBJECT (l->data);
15+ entry_accessible = ATK_OBJECT (l->data);
16
17- if (entry == panel_indicator_entry_accessible_get_entry (PANEL_INDICATOR_ENTRY_ACCESSIBLE (accessible)))
18+ if (entry == panel_indicator_entry_accessible_get_entry (PANEL_INDICATOR_ENTRY_ACCESSIBLE (entry_accessible)))
19 {
20- if (GTK_IS_LABEL (entry->label))
21- atk_object_set_name (accessible, gtk_label_get_text (GTK_LABEL (entry->label)));
22- else if (GTK_IS_IMAGE (entry->image))
23- atk_object_set_name (accessible, atk_object_get_name (ATK_OBJECT (entry->image)));
24- atk_object_set_description (accessible, entry->accessible_desc);
25+ found = TRUE;
26 break;
27 }
28 }
29+
30+ if (!found)
31+ return;
32+
33+ if (GTK_IS_LABEL (entry->label))
34+ {
35+ widget_accessible = gtk_widget_get_accessible (GTK_WIDGET (entry->label));
36+ }
37+ else if (GTK_IS_IMAGE (entry->image))
38+ {
39+ widget_accessible = gtk_widget_get_accessible (GTK_WIDGET (entry->image));
40+ }
41+ else
42+ {
43+ g_warning ("a11y: Current entry is not a label or a image.");
44+ }
45+
46+ if (ATK_IS_OBJECT (widget_accessible))
47+ {
48+ gchar *name = (gchar*) atk_object_get_name (widget_accessible);
49+ gchar *description = (gchar*) entry->accessible_desc;
50+
51+ if (name == NULL)
52+ name = "";
53+
54+ if (description == NULL)
55+ description = "";
56+
57+ atk_object_set_name (entry_accessible, name);
58+ atk_object_set_description (entry_accessible, description);
59+ }
60 }
61
62 static void
63@@ -290,11 +320,11 @@
64 /* Setup the indicator object */
65 pia->priv->indicator = g_object_ref (data);
66 g_signal_connect (G_OBJECT (pia->priv->indicator), "entry-added",
67- G_CALLBACK (on_indicator_entry_added), pia);
68+ G_CALLBACK (on_indicator_entry_added), pia);
69 g_signal_connect (G_OBJECT (pia->priv->indicator), "entry-removed",
70- G_CALLBACK (on_indicator_entry_removed), pia);
71+ G_CALLBACK (on_indicator_entry_removed), pia);
72 g_signal_connect (G_OBJECT (pia->priv->indicator), "accessible_desc_update",
73- G_CALLBACK (on_accessible_desc_updated), pia);
74+ G_CALLBACK (on_accessible_desc_updated), pia);
75
76 /* Retrieve all entries and create their accessible objects */
77 entries = indicator_object_get_entries (pia->priv->indicator);
78
79=== modified file 'services/panel-indicator-entry-accessible.c'
80--- services/panel-indicator-entry-accessible.c 2011-03-15 10:57:34 +0000
81+++ services/panel-indicator-entry-accessible.c 2011-09-02 15:02:24 +0000
82@@ -240,7 +240,8 @@
83 }
84 }
85
86- atk_object_set_description (accessible, piea->priv->entry->accessible_desc);
87+ if (piea->priv->entry->accessible_desc != NULL)
88+ atk_object_set_description (accessible, piea->priv->entry->accessible_desc);
89 }
90
91 static gint
92@@ -273,7 +274,10 @@
93 atk_object_set_parent (child, accessible);
94 }
95
96- return child;
97+ if (child != NULL)
98+ return g_object_ref (child);
99+ else
100+ return NULL;
101 }
102
103 static AtkStateSet *