Merge lp:~rodrigo-moya/unity/sync-geometries into lp:unity

Proposed by Rodrigo Moya
Status: Merged
Approved by: Rodrigo Moya
Approved revision: no longer in the source branch.
Merged at revision: 965
Proposed branch: lp:~rodrigo-moya/unity/sync-geometries
Merge into: lp:unity
Diff against target: 962 lines (+414/-100)
16 files modified
po/unity.pot (+0/-69)
services/CMakeLists.txt (+25/-15)
services/panel-a11y.c (+6/-0)
services/panel-indicator-accessible.c (+111/-4)
services/panel-indicator-entry-accessible.c (+85/-7)
services/panel-main.c (+31/-3)
services/panel-marshal.list (+1/-0)
services/panel-service.c (+28/-0)
services/panel-service.h (+7/-0)
src/IndicatorObjectFactory.h (+1/-0)
src/IndicatorObjectFactoryRemote.cpp (+3/-0)
src/PanelIndicatorObjectView.cpp (+2/-1)
src/PanelIndicatorObjectView.h (+1/-1)
src/PanelView.cpp (+101/-0)
src/PanelView.h (+3/-0)
tests/CMakeLists.txt (+9/-0)
To merge this branch: bzr merge lp:~rodrigo-moya/unity/sync-geometries
Reviewer Review Type Date Requested Status
Rodrigo Moya (community) Approve
Neil J. Patel (community) Approve
Alejandro Piñeiro (community) Approve
Review via email: mp+51929@code.launchpad.net

Description of the change

Sync geometries of the indicators from unity to the panel service, so that that information can be used to implement AtkComponent for both PanelIndicatorAccessible and PanelIndicatorEntryAccessible

To post a comment you must log in.
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

Note that there's something wrong with the geometries, and not all indicator objects/entries get highlighted in the correct position when selected in accerciser

Revision history for this message
Alejandro Piñeiro (apinheiro) wrote :

I have tested it with accerciser, and about this comment:
"Note that there's something wrong with the geometries, and not all indicator objects/entries get highlighted in the correct position when selected in accerciser"

I only got one indicator object/entry having the proper position.

About the code, in general seems good, although it would be required a review of the non accessibility related code (the methods and signals used by the AtkComponent implementation) except in one detail:

149 +panel_indicator_accessible_get_extents (AtkComponent *component,
150 + gint *x,
151 + gint *y,
152 + gint *width,
153 + gint *height,
154 + AtkCoordType coord_type)

309 +panel_indicator_entry_accessible_get_extents (AtkComponent *component,
310 + gint *x,
311 + gint *y,
312 + gint *width,
313 + gint *height,
314 + AtkCoordType coord_type)

You don't check coord_type at all. Take into account that the data that you return are totally different depending on coord_type. As far as I see, in both cases you try to return the result assuming global screen positions (ATK_XY_SCREEN), so it is missing the ATK_XY_WINDOW

In the same way, taking into account that you are already using the signal geometries_changed, I think that it would be easy to also emit the signal "bounds-changed":

http://library.gnome.org/devel/atk/stable/AtkComponent.html#AtkComponent-bounds-changed

BTW, about the signals. Each time that you receive this signal the size is updated, but, what happen with the initial state? Initially this is set to zero. That means that if the indicators/entry has already his position/size set before the accessible object is created, it will have a wrong position/size value? (as it is not updated by the signal)?

review: Needs Fixing
Revision history for this message
Alejandro Piñeiro (apinheiro) wrote :

BTW, although we already commented that via IRC, just to comment that the gen-marshal addition on cmake seems to not work properly, as I needed to execute it by hand.

Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

All issues fixed, so please review again

Revision history for this message
Alejandro Piñeiro (apinheiro) wrote :

519 + root = atk_get_root ();
520 +
521 gtk_main ();

This get_root could mean a crash if the a11y is not enabled. So options:

a) Add a method on panel-a11y to check if the accessibility is enabled.
b) Move this call inside panel_a11y_init. As it is required that the service is created to this root, that would mean move panel_a11y_init to the line of this atk_get_root

review: Needs Fixing
Revision history for this message
Alejandro Piñeiro (apinheiro) wrote :

Code seems ok, and I tested it and the position is more accurate.

Anyway:

 * Be careful with the .pot file included on this branch
 * I'm not used to cmake and you modify non-a11y related code, so it would be good to have a second opinion here

review: Approve
Revision history for this message
Neil J. Patel (njpatel) wrote :

Looks good, approved.

review: Approve
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

Neil gave his +1 on irc

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'po/unity.pot'
--- po/unity.pot 1970-01-01 00:00:00 +0000
+++ po/unity.pot 2011-03-17 12:04:28 +0000
@@ -0,0 +1,69 @@
1# SOME DESCRIPTIVE TITLE.
2# Copyright (C) YEAR Canonical\ Ltd
3# This file is distributed under the same license as the PACKAGE package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5#
6#, fuzzy
7msgid ""
8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: ayatana-dev@lists.launchpad.net\n"
11"POT-Creation-Date: 2011-02-21 19:06+0100\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"
15"Language: \n"
16"MIME-Version: 1.0\n"
17"Content-Type: text/plain; charset=CHARSET\n"
18"Content-Transfer-Encoding: 8bit\n"
19
20msgid "Keep In Launcher"
21msgstr ""
22
23msgid "Quit"
24msgstr ""
25
26msgid "Open"
27msgstr ""
28
29msgid "Eject"
30msgstr ""
31
32msgid "Workspace Switcher"
33msgstr ""
34
35msgid "Find Media Apps"
36msgstr ""
37
38msgid "Find Internet Apps"
39msgstr ""
40
41msgid "Find More Apps"
42msgstr ""
43
44msgid "Find Files"
45msgstr ""
46
47msgid "Browse the Web"
48msgstr ""
49
50msgid "View Photos"
51msgstr ""
52
53msgid "Check Email"
54msgstr ""
55
56msgid "Listen to Music"
57msgstr ""
58
59msgid "Trash"
60msgstr ""
61
62msgid "Empty Trash"
63msgstr ""
64
65msgid "Empty all items from Trash?"
66msgstr ""
67
68msgid "All items in the Trash will be permanently deleted."
69msgstr ""
070
=== removed file 'po/unity.pot'
--- po/unity.pot 2011-02-22 13:14:15 +0000
+++ po/unity.pot 1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
1# SOME DESCRIPTIVE TITLE.
2# Copyright (C) YEAR Canonical\ Ltd
3# This file is distributed under the same license as the PACKAGE package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5#
6#, fuzzy
7msgid ""
8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: ayatana-dev@lists.launchpad.net\n"
11"POT-Creation-Date: 2011-02-21 19:06+0100\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"
15"Language: \n"
16"MIME-Version: 1.0\n"
17"Content-Type: text/plain; charset=CHARSET\n"
18"Content-Transfer-Encoding: 8bit\n"
19
20msgid "Keep In Launcher"
21msgstr ""
22
23msgid "Quit"
24msgstr ""
25
26msgid "Open"
27msgstr ""
28
29msgid "Eject"
30msgstr ""
31
32msgid "Workspace Switcher"
33msgstr ""
34
35msgid "Find Media Apps"
36msgstr ""
37
38msgid "Find Internet Apps"
39msgstr ""
40
41msgid "Find More Apps"
42msgstr ""
43
44msgid "Find Files"
45msgstr ""
46
47msgid "Browse the Web"
48msgstr ""
49
50msgid "View Photos"
51msgstr ""
52
53msgid "Check Email"
54msgstr ""
55
56msgid "Listen to Music"
57msgstr ""
58
59msgid "Trash"
60msgstr ""
61
62msgid "Empty Trash"
63msgstr ""
64
65msgid "Empty all items from Trash?"
66msgstr ""
67
68msgid "All items in the Trash will be permanently deleted."
69msgstr ""
700
=== modified file 'services/CMakeLists.txt'
--- services/CMakeLists.txt 2011-02-24 14:51:30 +0000
+++ services/CMakeLists.txt 2011-03-17 12:04:28 +0000
@@ -7,6 +7,30 @@
7execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} indicator --variable indicatordir OUTPUT_VARIABLE _indicatordir OUTPUT_STRIP_TRAILING_WHITESPACE)7execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} indicator --variable indicatordir OUTPUT_VARIABLE _indicatordir OUTPUT_STRIP_TRAILING_WHITESPACE)
8execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} indicator --variable iconsdir OUTPUT_VARIABLE _iconsdir OUTPUT_STRIP_TRAILING_WHITESPACE)8execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} indicator --variable iconsdir OUTPUT_VARIABLE _iconsdir OUTPUT_STRIP_TRAILING_WHITESPACE)
99
10set(PANEL_SOURCES
11 panel-a11y.c
12 panel-a11y.h
13 panel-indicator-accessible.c
14 panel-indicator-accessible.h
15 panel-indicator-entry-accessible.c
16 panel-indicator-entry-accessible.h
17 panel-main.c
18 ${CMAKE_SOURCE_DIR}/services/panel-marshal.c
19 panel-root-accessible.c
20 panel-root-accessible.h
21 panel-service.c
22 panel-service.h
23 panel-util-accessible.c
24 panel-util-accessible.h)
25
26find_program(GLIB_GENMARSHAL glib-genmarshal)
27add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/services/panel-marshal.c
28 COMMAND ${GLIB_GENMARSHAL} ARGS panel-marshal.list --body --prefix=panel_marshal > ${CMAKE_SOURCE_DIR}/services/panel-marshal.c
29 COMMAND ${GLIB_GENMARSHAL} ARGS panel-marshal.list --header --prefix=panel_marshal > ${CMAKE_SOURCE_DIR}/services/panel-marshal.h
30 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
31 DEPENDS panel-marshal.list
32 COMMENT "Generating marshallers")
33
10set(CFLAGS34set(CFLAGS
11 ${SERVICE_DEPS_CFLAGS}35 ${SERVICE_DEPS_CFLAGS}
12 ${SERVICE_DEPS_CFLAGS_OTHER}36 ${SERVICE_DEPS_CFLAGS_OTHER}
@@ -24,21 +48,7 @@
24set(LIB_PATHS ${SERVICE_DEPS_LIBRARY_DIRS})48set(LIB_PATHS ${SERVICE_DEPS_LIBRARY_DIRS})
25link_directories(${LIB_PATHS})49link_directories(${LIB_PATHS})
2650
27add_executable(unity-panel-service51add_executable(unity-panel-service ${PANEL_SOURCES})
28 panel-a11y.c
29 panel-a11y.h
30 panel-indicator-accessible.c
31 panel-indicator-accessible.h
32 panel-indicator-entry-accessible.c
33 panel-indicator-entry-accessible.h
34 panel-main.c
35 panel-root-accessible.c
36 panel-root-accessible.h
37 panel-service.c
38 panel-service.h
39 panel-util-accessible.c
40 panel-util-accessible.h
41 )
42install(TARGETS unity-panel-service DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/unity/)52install(TARGETS unity-panel-service DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/unity/)
4353
44configure_file(com.canonical.Unity.Panel.Service.service.cmake ${CMAKE_CURRENT_BINARY_DIR}/com.canonical.Unity.Panel.Service.service)54configure_file(com.canonical.Unity.Panel.Service.service.cmake ${CMAKE_CURRENT_BINARY_DIR}/com.canonical.Unity.Panel.Service.service)
4555
=== modified file 'services/panel-a11y.c'
--- services/panel-a11y.c 2011-02-28 15:51:27 +0000
+++ services/panel-a11y.c 2011-03-17 12:04:28 +0000
@@ -127,6 +127,7 @@
127void127void
128panel_a11y_init (void)128panel_a11y_init (void)
129{129{
130 AtkObject *root;
130 gchar *bridge_path = NULL;131 gchar *bridge_path = NULL;
131132
132 if (a11y_initialized)133 if (a11y_initialized)
@@ -150,5 +151,10 @@
150151
151 g_free (bridge_path);152 g_free (bridge_path);
152153
154 /* There might be cases when we start signalling about change of geometries but the
155 accessible objects are not yet created, so to avoid that, instantiate here the
156 A11Y root object, which will create them all */
157 root = atk_get_root ();
158
153 a11y_initialized = TRUE;159 a11y_initialized = TRUE;
154}160}
155161
=== modified file 'services/panel-indicator-accessible.c'
--- services/panel-indicator-accessible.c 2011-03-14 17:01:34 +0000
+++ services/panel-indicator-accessible.c 2011-03-17 12:04:28 +0000
@@ -19,12 +19,11 @@
19#include <glib/gi18n.h>19#include <glib/gi18n.h>
20#include "panel-indicator-accessible.h"20#include "panel-indicator-accessible.h"
21#include "panel-indicator-entry-accessible.h"21#include "panel-indicator-entry-accessible.h"
2222#include "panel-service.h"
23G_DEFINE_TYPE(PanelIndicatorAccessible, panel_indicator_accessible, ATK_TYPE_OBJECT)
24
25#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_INDICATOR_ACCESSIBLE, PanelIndicatorAccessiblePrivate))
2623
27/* AtkObject methods */24/* AtkObject methods */
25static void pia_component_interface_init (AtkComponentIface *iface);
26
28static void panel_indicator_accessible_initialize (AtkObject *accessible, gpointer data);27static void panel_indicator_accessible_initialize (AtkObject *accessible, gpointer data);
29static gint panel_indicator_accessible_get_n_children (AtkObject *accessible);28static gint panel_indicator_accessible_get_n_children (AtkObject *accessible);
30static AtkObject *panel_indicator_accessible_ref_child (AtkObject *accessible, gint i);29static AtkObject *panel_indicator_accessible_ref_child (AtkObject *accessible, gint i);
@@ -33,9 +32,21 @@
33struct _PanelIndicatorAccessiblePrivate32struct _PanelIndicatorAccessiblePrivate
34{33{
35 IndicatorObject *indicator;34 IndicatorObject *indicator;
35 PanelService *service;
36 GSList *a11y_children;36 GSList *a11y_children;
37 gint x;
38 gint y;
39 gint width;
40 gint height;
37};41};
3842
43G_DEFINE_TYPE_WITH_CODE(PanelIndicatorAccessible,
44 panel_indicator_accessible,
45 ATK_TYPE_OBJECT,
46 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, pia_component_interface_init))
47
48#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_INDICATOR_ACCESSIBLE, PanelIndicatorAccessiblePrivate))
49
39/* Indicator callbacks */50/* Indicator callbacks */
4051
41static void52static void
@@ -100,6 +111,64 @@
100}111}
101112
102static void113static void
114on_geometries_changed_cb (PanelService *service,
115 IndicatorObject *object,
116 IndicatorObjectEntry *entry,
117 gint x,
118 gint y,
119 gint width,
120 gint height,
121 gpointer user_data)
122{
123 PanelIndicatorAccessible *pia;
124 AtkRectangle rect;
125 GSList *l;
126 gboolean minimum_set = FALSE;
127
128 pia = PANEL_INDICATOR_ACCESSIBLE (user_data);
129
130 g_return_if_fail (PANEL_IS_INDICATOR_ACCESSIBLE (pia));
131
132 if (object != pia->priv->indicator)
133 return;
134
135 /* Iterate over all children to get width and height */
136 pia->priv->width = pia->priv->height = 0;
137
138 for (l = pia->priv->a11y_children; l != NULL; l = l->next)
139 {
140 gint e_x, e_y, e_width, e_height;
141 AtkObject *accessible = ATK_OBJECT (l->data);
142
143 atk_component_get_extents (ATK_COMPONENT (accessible), &e_x, &e_y, &e_width, &e_height, ATK_XY_SCREEN);
144 if (minimum_set)
145 {
146 if (e_x < pia->priv->x)
147 pia->priv->x = e_x;
148 if (e_y < pia->priv->y)
149 pia->priv->y = e_y;
150 }
151 else
152 {
153 pia->priv->x = e_x;
154 pia->priv->y = e_y;
155 minimum_set = TRUE;
156 }
157
158 pia->priv->width += e_width;
159 if (e_height > pia->priv->height)
160 pia->priv->height = e_height;
161 }
162
163 /* Notify ATK objects of change of coordinates */
164 rect.x = pia->priv->x;
165 rect.y = pia->priv->y;
166 rect.width = pia->priv->width;
167 rect.height = pia->priv->height;
168 g_signal_emit_by_name (ATK_COMPONENT (pia), "bounds-changed", &rect);
169}
170
171static void
103panel_indicator_accessible_finalize (GObject *object)172panel_indicator_accessible_finalize (GObject *object)
104{173{
105 PanelIndicatorAccessible *pia = PANEL_INDICATOR_ACCESSIBLE (object);174 PanelIndicatorAccessible *pia = PANEL_INDICATOR_ACCESSIBLE (object);
@@ -122,6 +191,8 @@
122 pia->priv->a11y_children = g_slist_remove (pia->priv->a11y_children, accessible);191 pia->priv->a11y_children = g_slist_remove (pia->priv->a11y_children, accessible);
123 g_object_unref (accessible);192 g_object_unref (accessible);
124 }193 }
194
195 g_signal_handlers_disconnect_by_func (pia->priv->service, on_geometries_changed_cb, pia);
125 }196 }
126197
127 G_OBJECT_CLASS (panel_indicator_accessible_parent_class)->finalize (object);198 G_OBJECT_CLASS (panel_indicator_accessible_parent_class)->finalize (object);
@@ -152,6 +223,12 @@
152{223{
153 pia->priv = GET_PRIVATE (pia);224 pia->priv = GET_PRIVATE (pia);
154 pia->priv->a11y_children = NULL;225 pia->priv->a11y_children = NULL;
226 pia->priv->x = pia->priv->y = pia->priv->width = pia->priv->height = 0;
227
228 /* Set up signals for listening to service changes */
229 pia->priv->service = panel_service_get_default ();
230 g_signal_connect (pia->priv->service, "geometries-changed",
231 G_CALLBACK (on_geometries_changed_cb), pia);
155}232}
156233
157AtkObject *234AtkObject *
@@ -168,6 +245,36 @@
168/* Implementation of AtkObject methods */245/* Implementation of AtkObject methods */
169246
170static void247static void
248panel_indicator_accessible_get_extents (AtkComponent *component,
249 gint *x,
250 gint *y,
251 gint *width,
252 gint *height,
253 AtkCoordType coord_type)
254{
255 PanelIndicatorAccessible *pia;
256
257 g_return_if_fail (PANEL_IS_INDICATOR_ACCESSIBLE (component));
258
259 pia = PANEL_INDICATOR_ACCESSIBLE (component);
260
261 /* We ignore AtkCoordType for now, as the panel is always at the top left
262 corner and so relative and absolute coordinates are the same */
263 *x = pia->priv->x;
264 *y = pia->priv->y;
265 *width = pia->priv->width;
266 *height = pia->priv->height;
267}
268
269static void
270pia_component_interface_init (AtkComponentIface *iface)
271{
272 g_return_if_fail (iface != NULL);
273
274 iface->get_extents = panel_indicator_accessible_get_extents;
275}
276
277static void
171panel_indicator_accessible_initialize (AtkObject *accessible, gpointer data)278panel_indicator_accessible_initialize (AtkObject *accessible, gpointer data)
172{279{
173 PanelIndicatorAccessible *pia;280 PanelIndicatorAccessible *pia;
174281
=== modified file 'services/panel-indicator-entry-accessible.c'
--- services/panel-indicator-entry-accessible.c 2011-03-14 16:46:04 +0000
+++ services/panel-indicator-entry-accessible.c 2011-03-17 12:04:28 +0000
@@ -19,11 +19,9 @@
19#include "panel-indicator-entry-accessible.h"19#include "panel-indicator-entry-accessible.h"
20#include "panel-service.h"20#include "panel-service.h"
2121
22G_DEFINE_TYPE(PanelIndicatorEntryAccessible, panel_indicator_entry_accessible, ATK_TYPE_OBJECT)
23
24#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_INDICATOR_ENTRY_ACCESSIBLE, PanelIndicatorEntryAccessiblePrivate))
25
26/* AtkObject methods */22/* AtkObject methods */
23static void piea_component_interface_init (AtkComponentIface *iface);
24
27static void panel_indicator_entry_accessible_initialize (AtkObject *accessible, gpointer data);25static void panel_indicator_entry_accessible_initialize (AtkObject *accessible, gpointer data);
28static gint panel_indicator_entry_accessible_get_n_children (AtkObject *accessible);26static gint panel_indicator_entry_accessible_get_n_children (AtkObject *accessible);
29static AtkObject *panel_indicator_entry_accessible_ref_child (AtkObject *accessible, gint i);27static AtkObject *panel_indicator_entry_accessible_ref_child (AtkObject *accessible, gint i);
@@ -33,17 +31,30 @@
33{31{
34 IndicatorObjectEntry *entry;32 IndicatorObjectEntry *entry;
35 PanelService *service;33 PanelService *service;
34 gint x;
35 gint y;
36 gint width;
37 gint height;
36 gboolean active;38 gboolean active;
37};39};
3840
41G_DEFINE_TYPE_WITH_CODE(PanelIndicatorEntryAccessible,
42 panel_indicator_entry_accessible,
43 ATK_TYPE_OBJECT,
44 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, piea_component_interface_init))
45
46#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_INDICATOR_ENTRY_ACCESSIBLE, PanelIndicatorEntryAccessiblePrivate))
47
39static void48static void
40on_entry_activated_cb (PanelService *service, const gchar *entry_id, gpointer user_data)49on_entry_activated_cb (PanelService *service, const gchar *entry_id, gpointer user_data)
41{50{
42 gchar *s;51 gchar *s;
43 gboolean adding = FALSE;52 gboolean adding = FALSE;
44 PanelIndicatorEntryAccessible *piea = PANEL_INDICATOR_ENTRY_ACCESSIBLE (user_data);53 PanelIndicatorEntryAccessible *piea;
4554
46 g_return_if_fail (PANEL_IS_INDICATOR_ENTRY_ACCESSIBLE (piea));55 g_return_if_fail (PANEL_IS_INDICATOR_ENTRY_ACCESSIBLE (user_data));
56
57 piea = PANEL_INDICATOR_ENTRY_ACCESSIBLE (user_data);
4758
48 /* The PanelService sends us a string containing the pointer to the IndicatorObjectEntry */59 /* The PanelService sends us a string containing the pointer to the IndicatorObjectEntry */
49 s = g_strdup_printf ("%p", piea->priv->entry);60 s = g_strdup_printf ("%p", piea->priv->entry);
@@ -66,6 +77,39 @@
66}77}
6778
68static void79static void
80on_geometries_changed_cb (PanelService *service,
81 IndicatorObject *object,
82 IndicatorObjectEntry *entry,
83 gint x,
84 gint y,
85 gint width,
86 gint height,
87 gpointer user_data)
88{
89 PanelIndicatorEntryAccessible *piea;
90 AtkRectangle rect;
91
92 piea = PANEL_INDICATOR_ENTRY_ACCESSIBLE (user_data);
93
94 g_return_if_fail (PANEL_IS_INDICATOR_ENTRY_ACCESSIBLE (piea));
95
96 if (entry != piea->priv->entry)
97 return;
98
99 piea->priv->x = x;
100 piea->priv->y = y;
101 piea->priv->width = width;
102 piea->priv->height = height;
103
104 /* Notify ATK objects of change of coordinates */
105 rect.x = piea->priv->x;
106 rect.y = piea->priv->y;
107 rect.width = piea->priv->width;
108 rect.height = piea->priv->height;
109 g_signal_emit_by_name (ATK_COMPONENT (piea), "bounds-changed", &rect);
110}
111
112static void
69panel_indicator_entry_accessible_finalize (GObject *object)113panel_indicator_entry_accessible_finalize (GObject *object)
70{114{
71 PanelIndicatorEntryAccessible *piea;115 PanelIndicatorEntryAccessible *piea;
@@ -77,6 +121,7 @@
77 if (piea->priv != NULL)121 if (piea->priv != NULL)
78 {122 {
79 g_signal_handlers_disconnect_by_func (piea->priv->service, on_entry_activated_cb, piea);123 g_signal_handlers_disconnect_by_func (piea->priv->service, on_entry_activated_cb, piea);
124 g_signal_handlers_disconnect_by_func (piea->priv->service, on_geometries_changed_cb, piea);
80 }125 }
81126
82 G_OBJECT_CLASS (panel_indicator_entry_accessible_parent_class)->finalize (object);127 G_OBJECT_CLASS (panel_indicator_entry_accessible_parent_class)->finalize (object);
@@ -106,10 +151,13 @@
106panel_indicator_entry_accessible_init (PanelIndicatorEntryAccessible *piea)151panel_indicator_entry_accessible_init (PanelIndicatorEntryAccessible *piea)
107{152{
108 piea->priv = GET_PRIVATE (piea);153 piea->priv = GET_PRIVATE (piea);
154 piea->priv->x = piea->priv->y = piea->priv->width = piea->priv->height = 0;
109155
110 /* Set up signals for listening to service changes */156 /* Set up signals for listening to service changes */
111 piea->priv->active = FALSE;157 piea->priv->active = FALSE;
112 piea->priv->service = panel_service_get_default ();158 piea->priv->service = panel_service_get_default ();
159 g_signal_connect (piea->priv->service, "geometries-changed",
160 G_CALLBACK (on_geometries_changed_cb), piea);
113 g_signal_connect (piea->priv->service, "entry-activated",161 g_signal_connect (piea->priv->service, "entry-activated",
114 G_CALLBACK (on_entry_activated_cb), piea);162 G_CALLBACK (on_entry_activated_cb), piea);
115}163}
@@ -136,6 +184,36 @@
136/* Implementation of AtkObject methods */184/* Implementation of AtkObject methods */
137185
138static void186static void
187panel_indicator_entry_accessible_get_extents (AtkComponent *component,
188 gint *x,
189 gint *y,
190 gint *width,
191 gint *height,
192 AtkCoordType coord_type)
193{
194 PanelIndicatorEntryAccessible *piea;
195
196 g_return_if_fail (PANEL_IS_INDICATOR_ENTRY_ACCESSIBLE (component));
197
198 piea = PANEL_INDICATOR_ENTRY_ACCESSIBLE (component);
199
200 /* We ignore AtkCoordType for now, as the panel is always at the top left
201 corner and so relative and absolute coordinates are the same */
202 *x = piea->priv->x;
203 *y = piea->priv->y;
204 *width = piea->priv->width;
205 *height = piea->priv->height;
206}
207
208static void
209piea_component_interface_init (AtkComponentIface *iface)
210{
211 g_return_if_fail (iface != NULL);
212
213 iface->get_extents = panel_indicator_entry_accessible_get_extents;
214}
215
216static void
139panel_indicator_entry_accessible_initialize (AtkObject *accessible, gpointer data)217panel_indicator_entry_accessible_initialize (AtkObject *accessible, gpointer data)
140{218{
141 PanelIndicatorEntryAccessible *piea;219 PanelIndicatorEntryAccessible *piea;
142220
=== modified file 'services/panel-main.c'
--- services/panel-main.c 2011-01-31 21:52:38 +0000
+++ services/panel-main.c 2011-03-17 12:04:28 +0000
@@ -55,6 +55,10 @@
55 " <arg type='a(sssbbusbb)' name='state' direction='out'/>"55 " <arg type='a(sssbbusbb)' name='state' direction='out'/>"
56 " </method>"56 " </method>"
57 ""57 ""
58 " <method name='SyncGeometries'>"
59 " <arg type='a(ssiiii)' name='geometries' direction='in'/>"
60 " </method>"
61 ""
58 " <method name='ShowEntry'>"62 " <method name='ShowEntry'>"
59 " <arg type='s' name='entry_id' direction='in'/>"63 " <arg type='s' name='entry_id' direction='in'/>"
60 " <arg type='u' name='timestamp' direction='in'/>"64 " <arg type='u' name='timestamp' direction='in'/>"
@@ -140,6 +144,29 @@
140 id));144 id));
141 g_free (id);145 g_free (id);
142 }146 }
147 else if (g_strcmp0 (method_name, "SyncGeometries") == 0)
148 {
149 GVariantIter *iter;
150 gchar *indicator_id, *entry_id;
151 gint x, y, width, height;
152
153 g_variant_get (parameters, "(a(ssiiii))", &iter);
154 while (g_variant_iter_loop (iter, "(ssiiii)",
155 &indicator_id,
156 &entry_id,
157 &x,
158 &y,
159 &width,
160 &height))
161 {
162 panel_service_sync_geometry (service, indicator_id,
163 entry_id, x, y, width, height);
164 }
165
166 g_variant_iter_free (iter);
167
168 g_dbus_method_invocation_return_value (invocation, NULL);
169 }
143 else if (g_strcmp0 (method_name, "ShowEntry") == 0)170 else if (g_strcmp0 (method_name, "ShowEntry") == 0)
144 {171 {
145 gchar *entry_id;172 gchar *entry_id;
@@ -309,13 +336,11 @@
309 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default(),336 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default(),
310 INDICATORICONDIR);337 INDICATORICONDIR);
311338
312 panel_a11y_init ();
313
314 introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);339 introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
315 g_assert (introspection_data != NULL);340 g_assert (introspection_data != NULL);
316341
317 service = panel_service_get_default ();342 service = panel_service_get_default ();
318 343
319 owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,344 owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
320 S_NAME,345 S_NAME,
321 G_BUS_NAME_OWNER_FLAGS_NONE,346 G_BUS_NAME_OWNER_FLAGS_NONE,
@@ -324,6 +349,9 @@
324 on_name_lost,349 on_name_lost,
325 service,350 service,
326 NULL);351 NULL);
352
353 panel_a11y_init ();
354
327 gtk_main ();355 gtk_main ();
328356
329 g_bus_unown_name (owner_id);357 g_bus_unown_name (owner_id);
330358
=== added file 'services/panel-marshal.list'
--- services/panel-marshal.list 1970-01-01 00:00:00 +0000
+++ services/panel-marshal.list 2011-03-17 12:04:28 +0000
@@ -0,0 +1,1 @@
1NONE:OBJECT,POINTER,INT,INT,INT,INT
02
=== modified file 'services/panel-service.c'
--- services/panel-service.c 2011-03-09 00:11:25 +0000
+++ services/panel-service.c 2011-03-17 12:04:28 +0000
@@ -21,6 +21,7 @@
21#include <config.h>21#include <config.h>
22#endif22#endif
2323
24#include "panel-marshal.h"
24#include "panel-service.h"25#include "panel-service.h"
2526
26#include <stdlib.h>27#include <stdlib.h>
@@ -67,6 +68,7 @@
67 RE_SYNC,68 RE_SYNC,
68 ACTIVE_MENU_POINTER_MOTION,69 ACTIVE_MENU_POINTER_MOTION,
69 ENTRY_ACTIVATE_REQUEST,70 ENTRY_ACTIVATE_REQUEST,
71 GEOMETRIES_CHANGED,
7072
71 LAST_SIGNAL73 LAST_SIGNAL
72};74};
@@ -179,6 +181,16 @@
179 NULL, NULL,181 NULL, NULL,
180 g_cclosure_marshal_VOID__STRING,182 g_cclosure_marshal_VOID__STRING,
181 G_TYPE_NONE, 1, G_TYPE_STRING);183 G_TYPE_NONE, 1, G_TYPE_STRING);
184 _service_signals[GEOMETRIES_CHANGED] =
185 g_signal_new ("geometries-changed",
186 G_OBJECT_CLASS_TYPE (obj_class),
187 G_SIGNAL_RUN_LAST,
188 0,
189 NULL, NULL,
190 panel_marshal_VOID__OBJECT_POINTER_INT_INT_INT_INT,
191 G_TYPE_NONE, 6,
192 G_TYPE_OBJECT, G_TYPE_POINTER,
193 G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
182194
183195
184 g_type_class_add_private (obj_class, sizeof (PanelServicePrivate));196 g_type_class_add_private (obj_class, sizeof (PanelServicePrivate));
@@ -861,6 +873,22 @@
861 return g_variant_builder_end (&b);873 return g_variant_builder_end (&b);
862}874}
863875
876void
877panel_service_sync_geometry (PanelService *self,
878 const gchar *indicator_id,
879 const gchar *entry_id,
880 gint x,
881 gint y,
882 gint width,
883 gint height)
884{
885 PanelServicePrivate *priv = self->priv;
886 IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id);
887 IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);
888
889 g_signal_emit (self, _service_signals[GEOMETRIES_CHANGED], 0, object, entry, x, y, width, height);
890}
891
864static void892static void
865activate_next_prev_menu (PanelService *self,893activate_next_prev_menu (PanelService *self,
866 IndicatorObject *object,894 IndicatorObject *object,
867895
=== modified file 'services/panel-service.h'
--- services/panel-service.h 2011-02-23 16:49:18 +0000
+++ services/panel-service.h 2011-03-17 12:04:28 +0000
@@ -80,6 +80,13 @@
8080
81GVariant * panel_service_sync_one (PanelService *self,81GVariant * panel_service_sync_one (PanelService *self,
82 const gchar *indicator_id);82 const gchar *indicator_id);
83void panel_service_sync_geometry (PanelService *self,
84 const gchar *indicator_id,
85 const gchar *entry_id,
86 gint x,
87 gint y,
88 gint width,
89 gint height);
8390
84void panel_service_show_entry (PanelService *self,91void panel_service_show_entry (PanelService *self,
85 const gchar *entry_id,92 const gchar *entry_id,
8693
=== modified file 'src/IndicatorObjectFactory.h'
--- src/IndicatorObjectFactory.h 2010-12-17 14:07:11 +0000
+++ src/IndicatorObjectFactory.h 2011-03-17 12:04:28 +0000
@@ -47,6 +47,7 @@
47 sigc::signal<void, int, int> OnMenuPointerMoved;47 sigc::signal<void, int, int> OnMenuPointerMoved;
48 sigc::signal<void, const char *> OnEntryActivateRequest;48 sigc::signal<void, const char *> OnEntryActivateRequest;
49 sigc::signal<void, const char *> OnEntryActivated;49 sigc::signal<void, const char *> OnEntryActivated;
50 sigc::signal<void> OnSynced;
5051
51protected:52protected:
52 std::vector<IndicatorObjectProxy *>_indicators;53 std::vector<IndicatorObjectProxy *>_indicators;
5354
=== modified file 'src/IndicatorObjectFactoryRemote.cpp'
--- src/IndicatorObjectFactoryRemote.cpp 2011-01-11 15:48:03 +0000
+++ src/IndicatorObjectFactoryRemote.cpp 2011-03-17 12:04:28 +0000
@@ -358,6 +358,9 @@
358 358
359 g_free (current_proxy_id);359 g_free (current_proxy_id);
360 g_variant_iter_free (iter);360 g_variant_iter_free (iter);
361
362 /* Notify listeners we have new data */
363 OnSynced.emit ();
361}364}
362365
363void366void
364367
=== modified file 'src/PanelIndicatorObjectView.cpp'
--- src/PanelIndicatorObjectView.cpp 2011-02-22 23:11:20 +0000
+++ src/PanelIndicatorObjectView.cpp 2011-03-17 12:04:28 +0000
@@ -18,6 +18,7 @@
18 */18 */
1919
20#include "Nux/Nux.h"20#include "Nux/Nux.h"
21#include "Nux/Area.h"
21#include "Nux/HLayout.h"22#include "Nux/HLayout.h"
22#include "Nux/VLayout.h"23#include "Nux/VLayout.h"
2324
@@ -75,7 +76,6 @@
75void76void
76PanelIndicatorObjectView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)77PanelIndicatorObjectView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)
77{78{
78
79}79}
8080
81void81void
@@ -153,3 +153,4 @@
153 g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));153 g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));
154 g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));154 g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));
155}155}
156
156157
=== modified file 'src/PanelIndicatorObjectView.h'
--- src/PanelIndicatorObjectView.h 2011-01-25 15:45:12 +0000
+++ src/PanelIndicatorObjectView.h 2011-03-17 12:04:28 +0000
@@ -43,7 +43,7 @@
43 void OnEntryAdded (IndicatorObjectEntryProxy *proxy);43 void OnEntryAdded (IndicatorObjectEntryProxy *proxy);
44 void OnEntryMoved (IndicatorObjectEntryProxy *proxy);44 void OnEntryMoved (IndicatorObjectEntryProxy *proxy);
45 void OnEntryRemoved (IndicatorObjectEntryProxy *proxy);45 void OnEntryRemoved (IndicatorObjectEntryProxy *proxy);
4646
47 nux::HLayout *_layout;47 nux::HLayout *_layout;
4848
49protected:49protected:
5050
=== modified file 'src/PanelView.cpp'
--- src/PanelView.cpp 2011-03-16 09:45:39 +0000
+++ src/PanelView.cpp 2011-03-17 12:04:28 +0000
@@ -37,6 +37,10 @@
37#include "IndicatorObjectFactoryRemote.h"37#include "IndicatorObjectFactoryRemote.h"
38#include "PanelIndicatorObjectView.h"38#include "PanelIndicatorObjectView.h"
3939
40#define S_NAME "com.canonical.Unity.Panel.Service"
41#define S_PATH "/com/canonical/Unity/Panel/Service"
42#define S_IFACE "com.canonical.Unity.Panel.Service"
43
40NUX_IMPLEMENT_OBJECT_TYPE (PanelView);44NUX_IMPLEMENT_OBJECT_TYPE (PanelView);
4145
42PanelView::PanelView (NUX_FILE_LINE_DECL)46PanelView::PanelView (NUX_FILE_LINE_DECL)
@@ -44,6 +48,7 @@
44 _is_dirty (true),48 _is_dirty (true),
45 _opacity (1.0f)49 _opacity (1.0f)
46{50{
51 _needs_geo_sync = false;
47 _style = new PanelStyle ();52 _style = new PanelStyle ();
48 _style->changed.connect (sigc::mem_fun (this, &PanelView::ForceUpdateBackground));53 _style->changed.connect (sigc::mem_fun (this, &PanelView::ForceUpdateBackground));
4954
@@ -70,6 +75,7 @@
70 _remote->OnMenuPointerMoved.connect (sigc::mem_fun (this, &PanelView::OnMenuPointerMoved));75 _remote->OnMenuPointerMoved.connect (sigc::mem_fun (this, &PanelView::OnMenuPointerMoved));
71 _remote->OnEntryActivateRequest.connect (sigc::mem_fun (this, &PanelView::OnEntryActivateRequest));76 _remote->OnEntryActivateRequest.connect (sigc::mem_fun (this, &PanelView::OnEntryActivateRequest));
72 _remote->IndicatorObjectFactory::OnEntryActivated.connect (sigc::mem_fun (this, &PanelView::OnEntryActivated));77 _remote->IndicatorObjectFactory::OnEntryActivated.connect (sigc::mem_fun (this, &PanelView::OnEntryActivated));
78 _remote->IndicatorObjectFactory::OnSynced.connect (sigc::mem_fun (this, &PanelView::OnSynced));
73}79}
7480
75PanelView::~PanelView ()81PanelView::~PanelView ()
@@ -122,6 +128,12 @@
122 gPainter.PopBackground ();128 gPainter.PopBackground ();
123129
124 GfxContext.PopClippingRectangle ();130 GfxContext.PopClippingRectangle ();
131
132 if (_needs_geo_sync)
133 {
134 SyncGeometries ();
135 _needs_geo_sync = false;
136 }
125}137}
126138
127void139void
@@ -333,6 +345,12 @@
333 _menu_view->AllMenusClosed ();345 _menu_view->AllMenusClosed ();
334}346}
335347
348void
349PanelView::OnSynced ()
350{
351 _needs_geo_sync = true;
352}
353
336//354//
337// Useful Public Methods355// Useful Public Methods
338//356//
@@ -390,3 +408,86 @@
390 408
391 ForceUpdateBackground ();409 ForceUpdateBackground ();
392}410}
411
412static void
413on_sync_geometries_done_cb (GObject *source,
414 GAsyncResult *res,
415 gpointer data)
416{
417 GVariant *args;
418 GError *error = NULL;
419
420 args = g_dbus_proxy_call_finish ((GDBusProxy*) source, res, &error);
421 if (error != NULL)
422 {
423 g_warning ("Error when calling SyncGeometries: %s", error->message);
424 g_error_free (error);
425 }
426}
427
428void
429PanelView::SyncGeometries ()
430{
431 GVariantBuilder b;
432 GDBusProxy *bus_proxy;
433 GVariant *method_args;
434 std::list<Area *>::iterator it;
435
436 g_variant_builder_init (&b, G_VARIANT_TYPE ("(a(ssiiii))"));
437 g_variant_builder_open (&b, G_VARIANT_TYPE ("a(ssiiii)"));
438
439 std::list<Area *> my_children = _layout->GetChildren ();
440 for (it = my_children.begin(); it != my_children.end(); it++)
441 {
442 PanelIndicatorObjectView *view = static_cast<PanelIndicatorObjectView *> (*it);
443
444 if (view->_layout == NULL)
445 continue;
446
447 std::list<Area *>::iterator it2;
448
449 std::list<Area *> its_children = view->_layout->GetChildren ();
450 for (it2 = its_children.begin (); it2 != its_children.end (); it2++)
451 {
452 nux::Geometry geo;
453 PanelIndicatorObjectEntryView *entry = static_cast<PanelIndicatorObjectEntryView *> (*it2);
454
455 if (entry == NULL)
456 continue;
457
458 geo = entry->GetAbsoluteGeometry ();
459 g_variant_builder_add (&b, "(ssiiii)",
460 GetName (),
461 entry->_proxy->GetId (),
462 geo.x,
463 geo.y,
464 geo.GetWidth (),
465 geo.GetHeight ());
466 }
467 }
468
469 g_variant_builder_close (&b);
470 method_args = g_variant_builder_end (&b);
471
472 // Send geometries to the panel service
473 bus_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
474 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
475 NULL,
476 S_NAME,
477 S_PATH,
478 S_IFACE,
479 NULL,
480 NULL);
481 if (bus_proxy != NULL)
482 {
483 g_dbus_proxy_call (bus_proxy, "SyncGeometries", method_args,
484 G_DBUS_CALL_FLAGS_NONE,
485 -1,
486 NULL,
487 on_sync_geometries_done_cb,
488 this);
489 g_object_unref (bus_proxy);
490 }
491
492 g_variant_unref (method_args);
493}
393494
=== modified file 'src/PanelView.h'
--- src/PanelView.h 2011-03-16 09:45:39 +0000
+++ src/PanelView.h 2011-03-17 12:04:28 +0000
@@ -51,6 +51,7 @@
51 void OnMenuPointerMoved (int x, int y);51 void OnMenuPointerMoved (int x, int y);
52 void OnEntryActivateRequest (const char *entry_id);52 void OnEntryActivateRequest (const char *entry_id);
53 void OnEntryActivated (const char *entry_id);53 void OnEntryActivated (const char *entry_id);
54 void OnSynced ();
54 55
55 PanelHomeButton * HomeButton ();56 PanelHomeButton * HomeButton ();
5657
@@ -70,6 +71,7 @@
70private:71private:
71 void UpdateBackground ();72 void UpdateBackground ();
72 void ForceUpdateBackground ();73 void ForceUpdateBackground ();
74 void SyncGeometries ();
7375
74private:76private:
75 IndicatorObjectFactoryRemote *_remote;77 IndicatorObjectFactoryRemote *_remote;
@@ -86,6 +88,7 @@
86 PanelStyle *_style;88 PanelStyle *_style;
87 bool _is_dirty;89 bool _is_dirty;
88 float _opacity;90 float _opacity;
91 bool _needs_geo_sync;
89};92};
9093
91#endif // PANEL_VIEW_H94#endif // PANEL_VIEW_H
9295
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2011-03-11 14:43:50 +0000
+++ tests/CMakeLists.txt 2011-03-17 12:04:28 +0000
@@ -30,6 +30,14 @@
3030
31include_directories (. .. ../services ${CMAKE_BINARY_DIR})31include_directories (. .. ../services ${CMAKE_BINARY_DIR})
3232
33find_program(GLIB_GENMARSHAL glib-genmarshal)
34add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/services/panel-marshal.c
35 COMMAND ${GLIB_GENMARSHAL} ARGS ${CMAKE_SOURCE_DIR}/services/panel-marshal.list --body --prefix=panel_marshal > ${CMAKE_SOURCE_DIR}/services/panel-marshal.c
36 COMMAND ${GLIB_GENMARSHAL} ARGS ${CMAKE_SOURCE_DIR}/services/panel-marshal.list --header --prefix=panel_marshal > ${CMAKE_SOURCE_DIR}/services/panel-marshal.h
37 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
38 DEPENDS ../services/panel-marshal.list
39 COMMENT "Generating marshallers")
40
33# We can't have convenience libs so we need to rebuild with what we need41# We can't have convenience libs so we need to rebuild with what we need
34# Please keep actual test files alphabetically at top and then files42# Please keep actual test files alphabetically at top and then files
35# from ../../src or ../../services in alphabetically after that43# from ../../src or ../../services in alphabetically after that
@@ -44,6 +52,7 @@
44 ../src/ubus-server.h52 ../src/ubus-server.h
45 ../services/panel-service.c53 ../services/panel-service.c
46 ../services/panel-service.h54 ../services/panel-service.h
55 ${CMAKE_SOURCE_DIR}/services/panel-marshal.c
47 ../src/FavoriteStore.cpp56 ../src/FavoriteStore.cpp
48 ../src/FavoriteStore.h57 ../src/FavoriteStore.h
49 ../src/FavoriteStoreGSettings.cpp58 ../src/FavoriteStoreGSettings.cpp