Merge lp://qastaging/~bratsche/xsplash/configurable-signals into lp://qastaging/xsplash

Proposed by Cody Russell
Status: Superseded
Proposed branch: lp://qastaging/~bratsche/xsplash/configurable-signals
Merge into: lp://qastaging/xsplash
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~bratsche/xsplash/configurable-signals
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Needs Fixing
Review via email: mp+11082@code.qastaging.launchpad.net

This proposal has been superseded by a proposal from 2009-09-08.

Commit message

configurable signals

To post a comment you must log in.
Revision history for this message
Cody Russell (bratsche) wrote :

Since alpha5 is done, I'm going to go ahead and propose merging this branch.

This branch removes hard-coded signal names. Applications (e.g., nautilus, gnome-panel, netbook-launcher, gnome-shell, xfce) would instead install a file to /etc/xsplash. The filename would be the name of the signal they emit to xsplash. The file won't be read by xsplash, it will only look for the filename.

So if gnome-panel sends a signal to xsplash that identifies itself as "gnome-panel", it should touch /etc/xsplash/gnome-panel when it is being installed.

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

Looks good, had a couple of points:

configure_signals:
 - I'd normally use slightly more higher-level API such as g_dir_open, g_dir_read_names and g_dir_close, as I think they protect you from some errors (as well as giving you some useful GError's if somethings gone wrong).
 - Speaking of g_dir_close, I don't see *d being closed :)

add_signal:
 - I'd use g_strcmp0 instead of strcmp as it'll protect you if name == NULL
 - g_slist_next just expands to signal->next, so maybe that looks cleaner (this is just style stuff, so ignore me if you want :)?

last block of code:
 - Generally, I'd s/strcmp/g_strcmp0 as mentioned before
 - If you find the matching string and you delete the link, you should also break out of the forloop as deleting a link half-way through an iteration could invalidate the list pointers (afaik)?.

review: Needs Fixing
63. By Cody Russell

set_signals

64. By Cody Russell

remove configure_signals()

65. By Cody Russell

Remove SetSignals from dbus xml, replace with AddWaitSignal

66. By Cody Russell

Remove some old info from help output

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/xsplash.c'
2--- src/xsplash.c 2009-09-02 14:04:26 +0000
3+++ src/xsplash.c 2009-09-02 19:04:33 +0000
4@@ -22,6 +22,7 @@
5 #include <string.h>
6 #include <unistd.h>
7 #include <pwd.h>
8+#include <dirent.h>
9
10 #include <gtk/gtk.h>
11 #include <gdk/gdkkeysyms.h>
12@@ -61,9 +62,6 @@
13
14 GdkWindow *cow;
15 GdkScreen *screen;
16-
17- gboolean nautilus_done;
18- gboolean panel_done;
19 };
20
21 enum {
22@@ -73,29 +71,6 @@
23 PROP_DBUS_PROXY
24 };
25
26-#define XSPLASH_DBUS_NAME "com.ubuntu.BootCurtain"
27-#define XSPLASH_DBUS_OBJECT "/com/ubuntu/BootCurtain"
28-
29-static gboolean gdm_session = FALSE;
30-static gchar *background_image = NULL;
31-static gchar *logo_image = NULL;
32-static gchar *throbber_image = NULL;
33-static guint throbber_frames = 50;
34-static gboolean ping_pong = FALSE;
35-static gboolean have_xcomposite = FALSE;
36-static gboolean is_composited = FALSE;
37-static gboolean redirected = FALSE;
38-
39-static GOptionEntry entries[] = {
40- { "gdm-session", 'g', 0, G_OPTION_ARG_NONE, &gdm_session, "Run in gdm session", NULL },
41- { "background", 'b', 0, G_OPTION_ARG_FILENAME, &background_image, "Filename for background image", NULL },
42- { "logo", 'l', 0, G_OPTION_ARG_FILENAME, &logo_image, "Filename for logo image", NULL },
43- { "throbber", 't', 0, G_OPTION_ARG_FILENAME, &throbber_image, "Filename for throbber image", NULL },
44- { "frames", 'f', 0, G_OPTION_ARG_INT, &throbber_frames, "Number of frames for the throbber (default 50)", NULL },
45- { "pingpong", 'p', 0, G_OPTION_ARG_NONE, &ping_pong, "Whether to reverse throbber directions", NULL },
46- { NULL }
47-};
48-
49 static AnimContext * anim_context_new (XsplashServer *server,
50 GtyTimeline *timeline,
51 gpointer id);
52@@ -131,6 +106,65 @@
53 gdouble progress,
54 gpointer user_data);
55
56+static void add_signal (gchar *name);
57+static void xsplash_add_signal (const gchar *option_name,
58+ const gchar *value,
59+ gpointer data,
60+ GError **error);
61+
62+#define XSPLASH_DBUS_NAME "com.ubuntu.BootCurtain"
63+#define XSPLASH_DBUS_OBJECT "/com/ubuntu/BootCurtain"
64+
65+static gboolean gdm_session = FALSE;
66+static gchar *background_image = NULL;
67+static gchar *logo_image = NULL;
68+static gchar *throbber_image = NULL;
69+static guint throbber_frames = 50;
70+static gboolean ping_pong = FALSE;
71+static gboolean have_xcomposite = FALSE;
72+static gboolean is_composited = FALSE;
73+static gboolean redirected = FALSE;
74+static GSList *signal_list = NULL;
75+
76+static GOptionEntry entries[] = {
77+ {
78+ "gdm-session", 'g', 0,
79+ G_OPTION_ARG_NONE, &gdm_session,
80+ "Run in gdm session", NULL
81+ },
82+ {
83+ "background", 'b', 0,
84+ G_OPTION_ARG_FILENAME, &background_image,
85+ "Filename for background image", NULL
86+ },
87+ {
88+ "logo", 'l', 0,
89+ G_OPTION_ARG_FILENAME, &logo_image,
90+ "Filename for logo image", NULL
91+ },
92+ {
93+ "throbber", 't', 0,
94+ G_OPTION_ARG_FILENAME, &throbber_image,
95+ "Filename for throbber image", NULL
96+ },
97+ {
98+ "frames", 'f', 0,
99+ G_OPTION_ARG_INT, &throbber_frames,
100+ "Number of frames for the throbber (default 50)", NULL
101+ },
102+ {
103+ "pingpong", 'p', 0,
104+ G_OPTION_ARG_NONE, &ping_pong,
105+ "Whether to reverse throbber directions", NULL
106+ },
107+ {
108+ "add-signal", 's', 0,
109+ G_OPTION_ARG_CALLBACK, (GOptionArgFunc) xsplash_add_signal,
110+ "Add a signal to listen for. Alternately signals can be added to the XSPLASH_WAITFOR environment.", NULL
111+ },
112+ { NULL }
113+};
114+
115 #include "dbus-xsplash-server.h"
116
117 G_DEFINE_TYPE (XsplashServer, xsplash_server, G_TYPE_OBJECT);
118@@ -145,7 +179,7 @@
119
120 g_type_class_add_private (class, sizeof (XsplashServerPrivate));
121
122- object_class->dispose = xsplash_server_dispose;
123+ object_class->dispose = xsplash_server_dispose;
124 object_class->set_property = set_property;
125 object_class->get_property = get_property;
126
127@@ -219,8 +253,6 @@
128 g_return_if_reached ();
129 break;
130 }
131-
132- return;
133 }
134
135 static void
136@@ -245,8 +277,6 @@
137 g_return_if_reached ();
138 break;
139 }
140-
141- return;
142 }
143
144 static GdkPixbuf *
145@@ -292,7 +322,7 @@
146 }
147 else
148 {
149- g_debug (" ** %dx%d is too small, using last good size.\n", widths[i], heights[i]);
150+ g_debug (" ** %dx%d is too small, using last good size.", widths[i], heights[i]);
151 break;
152 }
153 }
154@@ -301,7 +331,7 @@
155
156 ret = g_strdup_printf (DATADIR "/images/xsplash/bg_%dx%d.jpg", widths[last_good], heights[last_good]);
157
158- g_debug (" ** filename: %s\n", ret);
159+ g_debug (" ** filename: %s", ret);
160
161 return ret;
162 }
163@@ -331,7 +361,7 @@
164
165 if (throbber_image != NULL)
166 {
167- g_debug ("get_throbber_filename(): user provided a throbber on the command line; using that\n");
168+ g_debug ("get_throbber_filename(): user provided a throbber on the command line; using that");
169
170 return g_strdup (throbber_image);
171 }
172@@ -342,7 +372,7 @@
173 get_filename_size_modifier (width));
174
175 g_debug (" ** Chose `%s'", get_filename_size_modifier (width));
176- g_debug (" ** throbber filename is: %s\n", ret);
177+ g_debug (" ** throbber filename is: %s", ret);
178
179 return ret;
180 }
181@@ -359,7 +389,7 @@
182
183 if (logo_image != NULL)
184 {
185- g_debug ("get_logo_filename(): user provided a logo on the command line; using that\n");
186+ g_debug ("get_logo_filename(): user provided a logo on the command line; using that");
187
188 return g_strdup (logo_image);
189 }
190@@ -370,7 +400,7 @@
191 get_filename_size_modifier (width));
192
193 g_debug (" ** Chose `%s'", get_filename_size_modifier (width));
194- g_debug (" ** logo filename is: %s\n", ret);
195+ g_debug (" ** logo filename is: %s", ret);
196
197 return ret;
198 }
199@@ -427,6 +457,23 @@
200 }
201
202 static void
203+configure_signals (void)
204+{
205+ struct dirent *ent;
206+ DIR *d;
207+
208+ d = opendir ("/etc/xsplash");
209+
210+ if (d)
211+ {
212+ while ((ent = readdir (d)) != NULL)
213+ {
214+ add_signal (ent->d_name);
215+ }
216+ }
217+}
218+
219+static void
220 xsplash_server_init (XsplashServer *server)
221 {
222 XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server);
223@@ -441,6 +488,8 @@
224 priv->system_bus = NULL;
225 priv->bus_proxy = NULL;
226
227+ configure_signals ();
228+
229 if (gdk_display_supports_composite (gdk_display_get_default ()))
230 {
231 have_xcomposite = TRUE;
232@@ -743,6 +792,37 @@
233 return FALSE;
234 }
235
236+static void
237+add_signal (gchar *name)
238+{
239+ GSList *tmp = NULL;
240+
241+ if ((strcmp (name, ".") == 0) || strcmp (name, "..") == 0)
242+ return;
243+
244+ g_debug ("adding signal `%s'", name);
245+
246+ for (tmp = signal_list; tmp != NULL; tmp = g_slist_next (signal_list))
247+ {
248+ if (strcmp (tmp->data, name) == 0)
249+ {
250+ g_debug (" ** that signal is already being listened for; skipping");
251+ return;
252+ }
253+ }
254+
255+ signal_list = g_slist_prepend (signal_list, g_strdup (name));
256+}
257+
258+static void
259+xsplash_add_signal (const gchar *option_name,
260+ const gchar *value,
261+ gpointer data,
262+ GError **error)
263+{
264+ add_signal (g_strdup (value));
265+}
266+
267 void
268 sig_handler (int signum)
269 {
270@@ -808,6 +888,7 @@
271 g_debug ("throbber_image = %s", throbber_image);
272
273 system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
274+
275 bus_proxy = dbus_g_proxy_new_for_name (system_bus,
276 DBUS_SERVICE_DBUS,
277 DBUS_PATH_DBUS,
278@@ -850,6 +931,13 @@
279 if (throbber_image != NULL)
280 g_free (throbber_image);
281
282+ if (signal_list != NULL)
283+ {
284+ g_slist_foreach (signal_list, (GFunc)g_free, NULL);
285+ g_slist_free (signal_list);
286+ signal_list = NULL;
287+ }
288+
289 return 0;
290 }
291
292@@ -858,8 +946,6 @@
293 gchar *app,
294 GError **error)
295 {
296- XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server);
297-
298 g_debug ("received signal: %s", app);
299
300 if (gdm_session)
301@@ -869,19 +955,24 @@
302 }
303 else
304 {
305- if (strcmp (app, "nautilus") == 0)
306- {
307- priv->nautilus_done = TRUE;
308- }
309- else if (strcmp (app, "gnome-panel") == 0)
310- {
311- priv->panel_done = TRUE;
312- }
313-
314- if (priv->nautilus_done && priv->panel_done)
315- {
316- g_debug ("received both \"nautilus\" and \"panel\" signals: fading out");
317- begin_fade (server, TRUE);
318+ GSList *l = NULL;
319+
320+ /* Remove this signal if it's in our list; if the list is empty, begin fading */
321+ for (l = signal_list; l != NULL; l = l->next)
322+ {
323+ if (strcmp (app, (gchar *)l->data) == 0)
324+ {
325+ g_debug ("received signal %s", (gchar*)l->data);
326+
327+ g_free (l->data);
328+ signal_list = g_slist_delete_link (signal_list, l);
329+
330+ /* There are no more signals we are listening for */
331+ if (signal_list == NULL)
332+ {
333+ begin_fade (server, TRUE);
334+ }
335+ }
336 }
337 }
338

Subscribers

People subscribed via source and target branches