]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkmain.c
Support added for building using a GNU toolchain on Win32,
[~andy/gtk] / gtk / gtkmain.c
index 8e2a2f32411b95d42b2dcb449b3ebf950b8c70e2..fa558da93a7656d68e4c5ea5cf18209d86fcabad 100644 (file)
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
+
+/*
+ * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+ */
+
+#include "gdkx.h"              /* For GDK_WINDOWING */
+
+#if GDK_WINDOWING == GDK_WINDOWING_X11
 #include <X11/Xlocale.h>       /* so we get the right setlocale */
+#else
+#include <locale.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <gmodule.h>
 #include "gtkbutton.h"
 #include "gtkdnd.h"
-#include "gtkfeatures.h"
+#include "gtkcompat.h"
 #include "gtkhscrollbar.h"
 #include "gtkhseparator.h"
 #include "gtkmain.h"
@@ -165,17 +179,33 @@ gtk_check_version (guint required_major,
   return NULL;
 }
 
+#ifdef __EMX__
+static gchar *add_dll_suffix(gchar *module_name)
+{
+    gchar *suffix = strrchr(module_name, '.');
+    
+    if (!suffix || stricmp(suffix, ".dll"))
+    {
+       gchar *old = module_name;
+         
+       module_name = g_strconcat (module_name, ".dll", NULL);
+       g_free (old);
+    }
+    return (module_name);
+}
+#endif
 
-void
-gtk_init (int   *argc,
-         char ***argv)
+gboolean
+gtk_init_check (int     *argc,
+               char   ***argv)
 {
+  extern void gtk_object_post_arg_parsing_init (void);
   GSList *gtk_modules = NULL;
   GSList *slist;
   gchar *env_string = NULL;
 
   if (gtk_initialized)
-    return;
+    return TRUE;
 
 #if    0
   g_set_error_handler (gtk_error);
@@ -187,7 +217,8 @@ gtk_init (int        *argc,
   /* Initialize "gdk". We pass along the 'argc' and 'argv'
    *  parameters as they contain information that GDK uses
    */
-  gdk_init (argc, argv);
+  if (!gdk_init_check (argc, argv))
+    return FALSE;
 
   gdk_event_handler_set ((GdkEventFunc)gtk_main_do_event, NULL, NULL);
   
@@ -207,7 +238,11 @@ gtk_init (int       *argc,
     {
       gchar **modules, **as;
 
-      modules = g_strsplit (env_string, ":", -1);
+#ifndef __EMX__
+      modules = g_strsplit (env_string, G_SEARCHPATH_SEPARATOR_S, -1);
+#else
+      modules = g_strsplit (env_string, ";", -1);
+#endif
       for (as = modules; *as; as++)
        {
          if (**as)
@@ -324,16 +359,17 @@ gtk_init (int      *argc,
       
       module_name = slist->data;
       slist->data = NULL;
-      if (!(module_name[0] == '/' ||
-           (module_name[0] == 'l' &&
-            module_name[1] == 'i' &&
-            module_name[2] == 'b')))
+#ifndef __EMX__
+      if (!g_path_is_absolute (module_name))
        {
          gchar *old = module_name;
          
-         module_name = g_strconcat ("lib", module_name, ".so", NULL);
+         module_name = g_module_build_path (NULL, module_name);
          g_free (old);
        }
+#else
+      module_name = add_dll_suffix(module_name);
+#endif
       if (g_module_supported ())
        {
          module = g_module_open (module_name, G_MODULE_BIND_LAZY);
@@ -376,6 +412,7 @@ gtk_init (int        *argc,
   gtk_colormap = gdk_colormap_get_system ();
 
   gtk_type_init ();
+  gtk_object_post_arg_parsing_init ();
   gtk_signal_init ();
   gtk_rc_init ();
   
@@ -401,6 +438,27 @@ gtk_init (int       *argc,
        }
     }
   g_slist_free (gtk_modules);
+  
+#ifndef NATIVE_WIN32
+  /* No use warning on Win32, there aren't any non-devel versions anyhow... */
+  g_warning (""              "YOU ARE USING THE DEVEL BRANCH 1.3.x OF GTK+ WHICH IS CURRENTLY\n"
+            "                UNDER HEAVY DEVELOPMENT AND FREQUENTLY INTRODUCES INSTABILITIES.\n"
+            "                if you don't know why you are getting this, you probably want to\n"
+            "                use the stable branch which can be retrived from\n"
+            "                ftp://ftp.gtk.org/pub/gtk/v1.2/ or via CVS with\n"
+            "                cvs checkout -r glib-1-2 glib; cvs checkout -r gtk-1-2 gtk+");
+#endif
+
+  return TRUE;
+}
+void
+gtk_init (int *argc, char ***argv)
+{
+  if (!gtk_init_check (argc, argv))
+    {
+      g_warning ("cannot open display: %s", gdk_get_display ());
+      exit(1);
+    }
 }
 
 void