← Back to team overview

ayatana-commits team mailing list archive

[Branch ~xsplash-team/xsplash/trunk] Rev 62: configurable signals

 

Merge authors:
  Cody Russell (bratsche)
Related merge proposals:
  https://code.launchpad.net/~bratsche/xsplash/configurable-signals/+merge/11368
  proposed by: Cody Russell (bratsche)
  review: Approve - David Barth (dbarth)
  https://code.launchpad.net/~bratsche/xsplash/configurable-signals/+merge/11082
  proposed by: Cody Russell (bratsche)
  review: Needs Fixing - Neil J. Patel (njpatel)
------------------------------------------------------------
revno: 62 [merge]
committer: Cody Russell <crussell@xxxxxxxxxxxxx>
branch nick: xsplash
timestamp: Tue 2009-09-08 11:11:32 -0500
message:
  configurable signals
modified:
  src/xsplash-dbus.xml
  src/xsplash.c


--
lp:xsplash
https://code.launchpad.net/~xsplash-team/xsplash/trunk

Your team ayatana-commits is subscribed to branch lp:xsplash.
To unsubscribe from this branch go to https://code.launchpad.net/~xsplash-team/xsplash/trunk/+edit-subscription.
=== modified file 'src/xsplash-dbus.xml'
--- src/xsplash-dbus.xml	2009-08-06 11:24:01 +0000
+++ src/xsplash-dbus.xml	2009-09-08 15:05:37 +0000
@@ -2,6 +2,9 @@
 
 <node name="/">
   <interface name="com.ubuntu.BootCurtain">
+    <method name="AddWaitSignal">
+      <arg type="s" name="wait" direction="in" />
+    </method>
     <method name="SignalLoaded">
       <arg type="s" name="app" direction="in" />
     </method>

=== modified file 'src/xsplash.c'
--- src/xsplash.c	2009-09-04 16:28:58 +0000
+++ src/xsplash.c	2009-09-08 16:11:32 +0000
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <pwd.h>
+#include <dirent.h>
 
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
@@ -61,9 +62,6 @@
 
   GdkWindow       *cow;
   GdkScreen       *screen;
-
-  gboolean         nautilus_done;
-  gboolean         panel_done;
 };
 
 enum {
@@ -73,29 +71,6 @@
   PROP_DBUS_PROXY
 };
 
-#define XSPLASH_DBUS_NAME   "com.ubuntu.BootCurtain"
-#define XSPLASH_DBUS_OBJECT "/com/ubuntu/BootCurtain"
-
-static gboolean  gdm_session      = FALSE;
-static gchar    *background_image = NULL;
-static gchar    *logo_image       = NULL;
-static gchar    *throbber_image   = NULL;
-static guint     throbber_frames  = 50;
-static gboolean  ping_pong        = FALSE;
-static gboolean  have_xcomposite  = FALSE;
-static gboolean  is_composited    = FALSE;
-static gboolean  redirected       = FALSE;
-
-static GOptionEntry entries[] = {
-  { "gdm-session", 'g', 0, G_OPTION_ARG_NONE, &gdm_session, "Run in gdm session", NULL },
-  { "background", 'b', 0, G_OPTION_ARG_FILENAME, &background_image, "Filename for background image", NULL },
-  { "logo", 'l', 0, G_OPTION_ARG_FILENAME, &logo_image, "Filename for logo image", NULL },
-  { "throbber", 't', 0, G_OPTION_ARG_FILENAME, &throbber_image, "Filename for throbber image", NULL },
-  { "frames", 'f', 0, G_OPTION_ARG_INT, &throbber_frames, "Number of frames for the throbber (default 50)", NULL },
-  { "pingpong", 'p', 0, G_OPTION_ARG_NONE, &ping_pong, "Whether to reverse throbber directions", NULL },
-  { NULL }
-};
-
 static AnimContext *      anim_context_new               (XsplashServer  *server,
                                                           GtyTimeline    *timeline,
                                                           gpointer        id);
@@ -123,6 +98,9 @@
 
 static void               xsplash_server_dispose         (GObject        *object);
 
+gboolean                  xsplash_server_add_wait_signal (XsplashServer  *server,
+                                                          gchar          *waitfor,
+                                                          GError        **error);
 gboolean                  xsplash_server_signal_loaded   (XsplashServer  *server,
                                                           gchar          *app,
                                                           GError        **error);
@@ -131,6 +109,65 @@
                                                           gdouble         progress,
                                                           gpointer        user_data);
 
+static void               add_signal                     (gchar *name);
+static void               xsplash_add_signal             (const gchar    *option_name,
+                                                          const gchar    *value,
+                                                          gpointer        data,
+                                                          GError        **error);
+
+#define XSPLASH_DBUS_NAME   "com.ubuntu.BootCurtain"
+#define XSPLASH_DBUS_OBJECT "/com/ubuntu/BootCurtain"
+
+static gboolean  gdm_session      = FALSE;
+static gchar    *background_image = NULL;
+static gchar    *logo_image       = NULL;
+static gchar    *throbber_image   = NULL;
+static guint     throbber_frames  = 50;
+static gboolean  ping_pong        = FALSE;
+static gboolean  have_xcomposite  = FALSE;
+static gboolean  is_composited    = FALSE;
+static gboolean  redirected       = FALSE;
+static GSList   *signal_list      = NULL;
+
+static GOptionEntry entries[] = {
+  {
+    "gdm-session", 'g', 0,
+    G_OPTION_ARG_NONE, &gdm_session,
+    "Run in gdm session", NULL
+  },
+  {
+    "background", 'b', 0,
+    G_OPTION_ARG_FILENAME, &background_image,
+    "Filename for background image", NULL
+  },
+  {
+    "logo", 'l', 0,
+    G_OPTION_ARG_FILENAME, &logo_image,
+    "Filename for logo image", NULL
+  },
+  {
+    "throbber", 't', 0,
+    G_OPTION_ARG_FILENAME, &throbber_image,
+    "Filename for throbber image", NULL
+  },
+  {
+    "frames", 'f', 0,
+    G_OPTION_ARG_INT, &throbber_frames,
+    "Number of frames for the throbber (default 50)", NULL
+  },
+  {
+    "pingpong", 'p', 0,
+    G_OPTION_ARG_NONE, &ping_pong,
+    "Whether to reverse throbber directions", NULL
+  },
+  {
+    "add-signal", 's', 0,
+    G_OPTION_ARG_CALLBACK, (GOptionArgFunc) xsplash_add_signal,
+    "Add a signal to listen for.", NULL
+  },
+  { NULL }
+};
+
 #include "dbus-xsplash-server.h"
 
 G_DEFINE_TYPE (XsplashServer, xsplash_server, G_TYPE_OBJECT);
@@ -145,7 +182,7 @@
 
   g_type_class_add_private (class, sizeof (XsplashServerPrivate));
 
-  object_class->dispose = xsplash_server_dispose;
+  object_class->dispose      = xsplash_server_dispose;
   object_class->set_property = set_property;
   object_class->get_property = get_property;
 
@@ -219,8 +256,6 @@
     g_return_if_reached ();
     break;
   }
-
-  return;
 }
 
 static void
@@ -245,8 +280,6 @@
     g_return_if_reached ();
     break;
   }
-
-  return;
 }
 
 static GdkPixbuf *
@@ -292,7 +325,7 @@
         }
       else
         {
-          g_debug (" ** %dx%d is too small, using last good size.\n", widths[i], heights[i]);
+          g_debug (" ** %dx%d is too small, using last good size.", widths[i], heights[i]);
           break;
         }
     }
@@ -301,7 +334,7 @@
 
   ret = g_strdup_printf (DATADIR "/images/xsplash/bg_%dx%d.jpg", widths[last_good], heights[last_good]);
 
-  g_debug (" ** filename: %s\n", ret);
+  g_debug (" ** filename: %s", ret);
 
   return ret;
 }
@@ -331,7 +364,7 @@
 
   if (throbber_image != NULL)
     {
-      g_debug ("get_throbber_filename(): user provided a throbber on the command line; using that\n");
+      g_debug ("get_throbber_filename(): user provided a throbber on the command line; using that");
 
       return g_strdup (throbber_image);
     }
@@ -342,7 +375,7 @@
                          get_filename_size_modifier (width));
 
   g_debug (" ** Chose `%s'", get_filename_size_modifier (width));
-  g_debug (" ** throbber filename is: %s\n", ret);
+  g_debug (" ** throbber filename is: %s", ret);
 
   return ret;
 }
@@ -359,7 +392,7 @@
 
   if (logo_image != NULL)
     {
-      g_debug ("get_logo_filename(): user provided a logo on the command line; using that\n");
+      g_debug ("get_logo_filename(): user provided a logo on the command line; using that");
 
       return g_strdup (logo_image);
     }
@@ -370,7 +403,7 @@
                          get_filename_size_modifier (width));
 
   g_debug (" ** Chose `%s'", get_filename_size_modifier (width));
-  g_debug (" ** logo filename is: %s\n", ret);
+  g_debug (" ** logo filename is: %s", ret);
 
   return ret;
 }
@@ -743,6 +776,37 @@
   return FALSE;
 }
 
+static void
+add_signal (gchar *name)
+{
+  GSList *tmp = NULL;
+
+  if ((strcmp (name, ".") == 0) || strcmp (name, "..") == 0)
+    return;
+
+  g_debug ("adding signal `%s'", name);
+
+  for (tmp = signal_list; tmp != NULL; tmp = g_slist_next (signal_list))
+    {
+      if (strcmp (tmp->data, name) == 0)
+        {
+          g_debug ("   ** that signal is already being listened for; skipping");
+          return;
+        }
+    }
+
+  signal_list = g_slist_prepend (signal_list, g_strdup (name));
+}
+
+static void
+xsplash_add_signal (const gchar  *option_name,
+                    const gchar  *value,
+                    gpointer      data,
+                    GError      **error)
+{
+  add_signal (g_strdup (value));
+}
+
 void
 sig_handler (int signum)
 {
@@ -808,6 +872,7 @@
   g_debug ("throbber_image = %s", throbber_image);
 
   system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+
   bus_proxy = dbus_g_proxy_new_for_name (system_bus,
                                          DBUS_SERVICE_DBUS,
                                          DBUS_PATH_DBUS,
@@ -850,16 +915,36 @@
   if (throbber_image != NULL)
     g_free (throbber_image);
 
+  if (signal_list != NULL)
+    {
+      g_slist_foreach (signal_list, (GFunc)g_free, NULL);
+      g_slist_free (signal_list);
+      signal_list = NULL;
+    }
+
   return 0;
 }
 
 gboolean
+xsplash_server_add_wait_signal (XsplashServer  *server,
+                                gchar          *waitfor,
+                                GError        **error)
+{
+  g_debug ("received a new signal to wait for: %s", waitfor);
+
+  if (waitfor)
+    {
+      add_signal (waitfor);
+    }
+
+  return TRUE;
+}
+
+gboolean
 xsplash_server_signal_loaded (XsplashServer  *server,
                               gchar          *app,
                               GError        **error)
 {
-  XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server);
-
   g_debug ("received signal: %s", app);
 
   if (gdm_session)
@@ -869,19 +954,24 @@
     }
   else
     {
-      if (strcmp (app, "nautilus") == 0)
-        {
-          priv->nautilus_done = TRUE;
-        }
-      else if (strcmp (app, "gnome-panel") == 0)
-        {
-          priv->panel_done = TRUE;
-        }
-
-      if (priv->nautilus_done && priv->panel_done)
-        {
-	  g_debug ("received both \"nautilus\" and \"panel\" signals: fading out");
-          begin_fade (server, TRUE);
+      GSList *l = NULL;
+
+      /* Remove this signal if it's in our list; if the list is empty, begin fading */
+      for (l = signal_list; l != NULL; l = l->next)
+        {
+          if (strcmp (app, (gchar *)l->data) == 0)
+            {
+              g_debug ("received signal %s", (gchar*)l->data);
+
+              g_free (l->data);
+              signal_list = g_slist_delete_link (signal_list, l);
+
+              /* There are no more signals we are listening for */
+              if (signal_list == NULL)
+                {
+                  begin_fade (server, TRUE);
+                }
+            }
         }
     }