patches/gnome-session-07-wait-for-postrun.diff
author dcarbery
Fri, 24 Nov 2006 16:37:59 +0000
branch217update
changeset 19096 d542fc2c823e
parent 8396 3047112e1ba8
permissions -rw-r--r--
Merged trunk changes r9797:9829 into 217update branch.

diff -urN gnome-session-2.16.1/gnome-session/main.c gnome-session-2.16.1-hacked/gnome-session/main.c
--- gnome-session-2.16.1/gnome-session/main.c	2006-10-23 09:51:16.839150000 +1300
+++ gnome-session-2.16.1-hacked/gnome-session/main.c	2006-10-23 09:53:52.502604000 +1300
@@ -248,7 +248,68 @@
   RESPONSE_LOG_IN,
   RESPONSE_TRY_AGAIN
 };
-    
+
+static gboolean
+postrun_progress_update (gpointer data)
+{
+  int status = 0;
+  static int count = 0;
+  GError *error = NULL;
+  gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data));
+
+  if (count == 30) {
+    g_spawn_command_line_sync ("/usr/lib/postrun-query -c JDS_wait -e", 
+			       NULL, NULL, &status, &error);
+    count = 0;
+  }
+
+  if (status == 0) {
+    count++;
+    return TRUE;
+  }
+
+  gtk_main_quit ();
+  return FALSE;
+}
+
+static void
+gsm_wait_for_unfinished_postrun () 
+{
+  int status = 0;
+  GError *error = NULL; 
+
+  if (!g_spawn_command_line_sync ("/usr/lib/postrun-query -c JDS_wait -e",
+				  NULL, NULL, &status, &error)) {
+    /* no postrun-query? WTF? bail out and hope for the best :) */
+    return;
+  }
+
+  if (status == 0) {
+    GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+    GtkWidget *vbox = gtk_vbox_new (TRUE, 10);
+    GtkWidget *progress = gtk_progress_bar_new ();
+    GtkWidget *label;
+    gint func_ref;
+
+    label = gtk_label_new (_("Completing post install setup..."));
+
+    gtk_container_add (GTK_CONTAINER (window), vbox);
+    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
+    gtk_box_pack_start_defaults (GTK_BOX (vbox), label);
+    gtk_progress_bar_pulse (GTK_PROGRESS_BAR (progress));
+    func_ref = g_timeout_add (100, postrun_progress_update, progress);
+    gtk_box_pack_start_defaults (GTK_BOX (vbox), progress);
+
+    gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
+
+    gtk_widget_show_all (window);
+    gtk_main ();
+  
+    gtk_widget_destroy (window);
+    g_source_remove (func_ref);
+  }
+}
+
 static void
 gnome_login_check (void)
 {
@@ -393,7 +454,9 @@
 
   /* We need to do this as early as possible */
   gsm_set_display_properties ();
-  
+
+  gsm_wait_for_unfinished_postrun ();
+
   if (ORBit_proto_use ("IPv4") || ORBit_proto_use ("IPv6"))
     gnome_login_check ();