Merge lp:~ted/unity/upstart-event into lp:unity

Proposed by Ted Gould
Status: Merged
Approved by: Ted Gould
Approved revision: no longer in the source branch.
Merged at revision: 3351
Proposed branch: lp:~ted/unity/upstart-event
Merge into: lp:unity
Diff against target: 90 lines (+48/-0)
2 files modified
debian/control (+1/-0)
services/panel-service.c (+47/-0)
To merge this branch: bzr merge lp:~ted/unity/upstart-event
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
Mathieu Trudel-Lapierre Needs Fixing
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+160421@code.launchpad.net

Commit message

Upstart event for when the indicators are loaded by the panel service.

Description of the change

Adds an upstart event for when the indicators are loaded by the panel service. Allows us to start moving to much smarter startup.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Why not just using g_app_info_create_from_commandline ?

It internally does the same things, and it's nicer to read.

Revision history for this message
Ted Gould (ted) wrote :

On Tue, 2013-04-23 at 17:57 +0000, Marco Trevisan (Treviño) wrote:

> Why not just using g_app_info_create_from_commandline ?
>
> It internally does the same things, and it's nicer to read.

Because initctl isn't an application with a desktop file. It's just a
commandline utility, so there isn't really any app_info. Plus then I'd
also have an object to track instead of just being able to "fire and
forget" about the command line utility.

Revision history for this message
Ted Gould (ted) wrote :

Okay, tested this with an indicator-network job and it works! Cool.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Upstart has DBus methods to do this (EmitEvent). I feel it would be better to use them rather than spawning processes from indicators or from the shell.

review: Needs Fixing
Revision history for this message
Ted Gould (ted) wrote :

On Tue, 2013-04-30 at 23:07 +0000, Mathieu Trudel-Lapierre wrote:

> Upstart has DBus methods to do this (EmitEvent). I feel it would be
> better to use them rather than spawning processes from indicators or
> from the shell.

Can you work with James to get a library building to export that method?
He seems to be willing to entertain the idea.

Revision history for this message
Stephen M. Webb (bregma) wrote :

I think this is OK as a stopgap measure, and maybe should be queued for replacement when full upstart session management is in place.

review: Approve
Revision history for this message
Ted Gould (ted) wrote :

Is there any reason to not top-approve this? Was it forgotten or on purpos?

Revision history for this message
Ted Gould (ted) wrote :

No objections.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-04-10 22:17:15 +0000
3+++ debian/control 2013-04-23 21:10:33 +0000
4@@ -97,6 +97,7 @@
5 Architecture: any
6 Depends: ${shlibs:Depends},
7 ${misc:Depends},
8+ upstart,
9 Description: Services for the Unity interface
10 Unity is a desktop experience that sings. Designed by Canonical and the Ayatana
11 community, Unity is all about the combination of familiarity and the future. We
12
13=== modified file 'services/panel-service.c'
14--- services/panel-service.c 2013-03-07 16:02:10 +0000
15+++ services/panel-service.c 2013-04-23 21:10:33 +0000
16@@ -54,6 +54,7 @@
17 GHashTable *panel2entries_hash;
18
19 guint initial_sync_id;
20+ guint ready_signal_id;
21 gint32 timeouts[N_TIMEOUT_SLOTS];
22
23 IndicatorObjectEntry *last_entry;
24@@ -179,6 +180,12 @@
25 priv->initial_sync_id = 0;
26 }
27
28+ if (priv->ready_signal_id)
29+ {
30+ g_source_remove (priv->ready_signal_id);
31+ priv->ready_signal_id = 0;
32+ }
33+
34 for (i = 0; i < N_TIMEOUT_SLOTS; i++)
35 {
36 if (priv->timeouts[i] > 0)
37@@ -473,6 +480,45 @@
38 return FALSE;
39 }
40
41+static gboolean
42+ready_signal (PanelService *self)
43+{
44+ if (PANEL_IS_SERVICE (self))
45+ {
46+ GError * error = NULL;
47+ gchar * argv[] = {
48+ "initctl",
49+ "--session",
50+ "--user",
51+ "emit",
52+ "--no-wait",
53+ "indicators-loaded",
54+ NULL,
55+ };
56+
57+ g_spawn_async(NULL, /* Working Directory */
58+ argv,
59+ NULL, /* environment */
60+ G_SPAWN_SEARCH_PATH,
61+ NULL, NULL, /* child setup function */
62+ NULL, /* Pid */
63+ &error);
64+
65+ if (error != NULL)
66+ {
67+ /* NOTE: When we get to the point where we can start
68+ assuming upstart user sessions this can be escillated
69+ to a warning or higher */
70+ g_debug("Unable to signal indicators-loaded to upstart: %s", error->message);
71+ g_error_free(error);
72+ }
73+
74+ self->priv->ready_signal_id = 0;
75+ }
76+
77+ return FALSE;
78+}
79+
80 static void
81 panel_service_update_menu_keybinding (PanelService *self)
82 {
83@@ -570,6 +616,7 @@
84 panel_service_update_menu_keybinding (self);
85
86 priv->initial_sync_id = g_idle_add ((GSourceFunc)initial_resync, self);
87+ priv->ready_signal_id = g_idle_add ((GSourceFunc)ready_signal, self);
88 }
89
90 static gboolean