Fixes for Windows.
authorRichard Jones <rjones@redhat.com>
Fri, 28 Nov 2008 10:46:52 +0000 (10:46 +0000)
committerRichard Jones <rjones@redhat.com>
Fri, 28 Nov 2008 10:46:52 +0000 (10:46 +0000)
main.c

diff --git a/main.c b/main.c
index 039cf39..1761864 100644 (file)
--- a/main.c
+++ b/main.c
@@ -22,7 +22,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <alloca.h>
 
 #include <glib.h>
 #include <gtk/gtk.h>
@@ -102,16 +101,15 @@ static const char *title = "oVirt Viewer";
 
 /* Gtk widget styles.  Avoid installation hassles by keeping this
  * inside the binary.  It can still be overridden by the user (who
- * will do that?).
+ * will do that?)
  */
 static const char *styles =
-  "\
-style \"ovirt-viewer-yellow-box\"\n\
-{\n\
-  bg[NORMAL] = shade (1.5, \"yellow\")\n\
-}\n\
-widget \"*.ovirt-viewer-connection-area\" style \"ovirt-viewer-yellow-box\"\n\
-";
+  "style \"ovirt-viewer-yellow-box\"\n"
+  "{\n"
+  "  bg[NORMAL] = shade (1.5, \"yellow\")\n"
+  "}\n"
+  "widget \"*.ovirt-viewer-connection-area\" style \"ovirt-viewer-yellow-box\"\n"
+  ;
 
 /* Command-line arguments. */
 static int print_version = 0;
@@ -152,13 +150,19 @@ main (int argc, char *argv[])
    * The WUI thread keeps the UI updated by adding idle events which are
    * processed in the main thread - see:
    * http://mail.gnome.org/archives/gtk-app-devel-list/2007-March/msg00232.html
+   *
+   * Note that under Win32 you must confine all Gtk/Gdk interactions
+   * to a single thread - see:
+   * http://developer.gimp.org/api/2.0/gdk/gdk-Threads.html
    */
   if (!g_thread_supported ()) {
-     g_thread_init (NULL);
-     gdk_threads_init ();
+    g_thread_init (NULL);
+#ifndef WIN32
+    gdk_threads_init ();
+#endif
   } else {
-     fprintf (stderr, "GLib threads not supported or not working.");
-     exit (1);
+    fprintf (stderr, "GLib threads not supported or not working.");
+    exit (1);
   }
 
   gtk_init (&argc, &argv);
@@ -184,6 +188,8 @@ main (int argc, char *argv[])
   start_wui_thread ();
   start_ui ();
 
+  DEBUG ("entering the Gtk main loop");
+
   gtk_main ();
 
   stop_wui_thread ();
@@ -214,6 +220,8 @@ start_ui (void)
   GtkWidget *la_hbox;
   GtkWidget *notebook;
 
+  DEBUG ("creating viewer windows and menus");
+
   /* Parse styles. */
   gtk_rc_parse_string (styles);
 
@@ -375,7 +383,7 @@ connect_to_wui (GtkWidget *widget, gpointer data)
 
   /* https:// + hostname + /ovirt + \0 */
   len = 8 + strlen (hostname) + 6 + 1;
-  uri = alloca (len);
+  uri = g_alloca (len);
   snprintf (uri, len, HTTPS "://%s/ovirt", hostname);
 
   wui_thread_send_connect (uri);