diff dwt/internal/c/gtk.d @ 165:1b025870f242

debugging dynamic gtk2 load and gtk_init crash
author Frank Benoit <benoit@tionex.de>
date Sat, 16 Feb 2008 03:13:04 +0100
parents 1f0d924801f4
children 38afe5c8e5b7
line wrap: on
line diff
--- a/dwt/internal/c/gtk.d	Sat Feb 16 00:21:07 2008 +0100
+++ b/dwt/internal/c/gtk.d	Sat Feb 16 03:13:04 2008 +0100
@@ -1,4 +1,4 @@
-/******************************************************************************
+/******************************************************************************
     Based on the generated files from the BCD tool
     modified by: Frank Benoit <keinfarbton@googlemail.com>
 ******************************************************************************/
@@ -10,6 +10,61 @@
 public import dwt.internal.c.gdk;
 public import dwt.internal.c.glib_object;
 
+
+version=DYNLINK;
+
+version(DYNLINK){
+
+
+extern (C) int gtk_init_check(int *, char * * *);
+extern (C) char * gtk_set_locale();
+extern (C) extern uint gtk_interface_age;
+extern (C) extern uint gtk_binary_age;
+extern (C) extern uint gtk_micro_version;
+extern (C) extern uint gtk_minor_version;
+extern (C) extern uint gtk_major_version;
+
+
+    import tango.sys.SharedLib : SharedLib;
+    import tango.util.log.Trace;
+    struct Symbol{
+        char[] name;
+        void** symbol;
+    }
+}
+
+void loadLib(){
+    version(DYNLINK){
+        char[] libname = "libgtk-x11-2.0.so";
+
+        SharedLib lib = SharedLib.load( libname );
+        if( lib is null ){
+            lib = SharedLib.load( libname ~ ".0" );
+        }
+        return;
+        int loaded;
+        if ( lib !is null ) {
+            foreach( s; symbols_gtk ){
+                if( loaded >= 0 ) break;
+                try{
+                    *s.symbol = lib.getSymbol( s.name.ptr );
+                }
+                catch(Exception e){}
+                if( *s.symbol is null ){
+                    Trace.formatln( "{}: Symbol '{}' not found", libname, s.name );
+                }
+                else{
+                    loaded++;
+                }
+            }
+        } else {
+            Trace.formatln( "Could not load the library {}", libname );
+        }
+
+    }
+}
+
+
 extern(C):
 align(4):
 
@@ -7213,20 +7268,20 @@
 extern (C) void function(_GdkEvent *)gtk_main_do_event;
 extern (C) int function()gtk_events_pending;
 extern (C) void * function()gtk_get_default_language;
-extern (C) char * function()gtk_set_locale;
+//extern (C) char * function()gtk_set_locale;
 extern (C) void function()gtk_disable_setlocale;
 extern (C) void function(int)gtk_exit;
 extern (C) void * function(int)gtk_get_option_group;
 extern (C) int function(int *, char * * *, char *, _GOptionEntry *, char *, _GError * *)gtk_init_with_args;
-extern (C) int function(int *, char * * *)gtk_init_check;
+//extern (C) int function(int *, char * * *)gtk_init_check;
 extern (C) void function(int *, char * * *)gtk_init;
 extern (C) int function(int *, char * * *)gtk_parse_args;
 extern (C) char * function(uint, uint, uint)gtk_check_version;
-extern (C) extern uint* gtk_interface_age;
-extern (C) extern uint* gtk_binary_age;
-extern (C) extern uint* gtk_micro_version;
-extern (C) extern uint* gtk_minor_version;
-extern (C) extern uint* gtk_major_version;
+// extern (C) uint* gtk_interface_age;
+// extern (C) uint* gtk_binary_age;
+// extern (C) uint* gtk_micro_version;
+// extern (C) uint* gtk_minor_version;
+// extern (C) uint* gtk_major_version;
 extern (C) void function(aGtkList *)gtk_list_end_drag_selection;
 extern (C) void function(aGtkList *)gtk_list_undo_selection;
 extern (C) void function(aGtkList *, aGtkWidget *)gtk_list_toggle_row;
@@ -9650,7 +9705,7 @@
 extern (C) uint function()gtk_accel_group_get_type;
 
 
-Symbol[] symbols = [
+Symbol[] symbols_gtk = [
     { "gtk_vseparator_new",  cast(void**)& gtk_vseparator_new},
     { "gtk_vseparator_get_type",  cast(void**)& gtk_vseparator_get_type},
     { "gtk_vscale_new_with_range",  cast(void**)& gtk_vscale_new_with_range},
@@ -10621,20 +10676,20 @@
     { "gtk_main_do_event",  cast(void**)& gtk_main_do_event},
     { "gtk_events_pending",  cast(void**)& gtk_events_pending},
     { "gtk_get_default_language",  cast(void**)& gtk_get_default_language},
-    { "gtk_set_locale",  cast(void**)& gtk_set_locale},
+    //{ "gtk_set_locale",  cast(void**)& gtk_set_locale},
     { "gtk_disable_setlocale",  cast(void**)& gtk_disable_setlocale},
     { "gtk_exit",  cast(void**)& gtk_exit},
     { "gtk_get_option_group",  cast(void**)& gtk_get_option_group},
     { "gtk_init_with_args",  cast(void**)& gtk_init_with_args},
-    { "gtk_init_check",  cast(void**)& gtk_init_check},
+    //{ "gtk_init_check",  cast(void**)& gtk_init_check},
     { "gtk_init",  cast(void**)& gtk_init},
     { "gtk_parse_args",  cast(void**)& gtk_parse_args},
     { "gtk_check_version",  cast(void**)& gtk_check_version},
-    { "gtk_interface_age",  cast(void**)& gtk_interface_age},
-    { "gtk_binary_age",  cast(void**)& gtk_binary_age},
-    { "gtk_micro_version",  cast(void**)& gtk_micro_version},
-    { "gtk_minor_version",  cast(void**)& gtk_minor_version},
-    { "gtk_major_version",  cast(void**)& gtk_major_version},
+//     { "gtk_interface_age",  cast(void**)& gtk_interface_age},
+//     { "gtk_binary_age",  cast(void**)& gtk_binary_age},
+//     { "gtk_micro_version",  cast(void**)& gtk_micro_version},
+//     { "gtk_minor_version",  cast(void**)& gtk_minor_version},
+//     { "gtk_major_version",  cast(void**)& gtk_major_version},
     { "gtk_list_end_drag_selection",  cast(void**)& gtk_list_end_drag_selection},
     { "gtk_list_undo_selection",  cast(void**)& gtk_list_undo_selection},
     { "gtk_list_toggle_row",  cast(void**)& gtk_list_toggle_row},
@@ -12567,7 +12622,7 @@
     { "_gtk_container_focus_sort",  cast(void**)& _gtk_container_focus_sort},
     { "_gtk_container_dequeue_resize_handler",  cast(void**)& _gtk_container_dequeue_resize_handler},
     { "_gtk_container_child_composite_name",  cast(void**)& _gtk_container_child_composite_name},
-    { "_gtk_container_clear_resize_widgets",  cast(void**)& _gtk_container_clear_resize_widgets},
+//    { "_gtk_container_clear_resize_widgets",  cast(void**)& _gtk_container_clear_resize_widgets},
     { "_gtk_container_queue_resize",  cast(void**)& _gtk_container_queue_resize},
     { "gtk_container_forall",  cast(void**)& gtk_container_forall},
     { "gtk_container_child_get_property",  cast(void**)& gtk_container_child_get_property},