changeset 2205:a43a3f80ed32

GTK: Changes to include both dw_(int_)init() functions with deprecated. This allows binary-wise for both old style resource apps and GResource ones to function with the same library. Which one is used depends on whether DW_INCLUDE_DEPRECATED is defined at compile time. Some more thought needs to be given to whether DW_INCLUDE_DEPRECATED should be included in the dwindows-config --cflags because apps expecting GResources will fail to compile with DW_INCLUDE_DEPRECATED defined, due to the dw_init() macro.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 29 Nov 2020 08:31:47 +0000
parents b86ae2abb3b3
children 70460d0afd03
files dw.h gtk/dw.c gtk3/dw.c
diffstat 3 files changed, 32 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Sun Nov 29 05:29:11 2020 +0000
+++ b/dw.h	Sun Nov 29 08:31:47 2020 +0000
@@ -1642,11 +1642,10 @@
 void API dw_box_pack_at_index(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad);
 HWND API dw_box_unpack_at_index(HWND box, int index);
 int API dw_box_unpack(HWND handle);
+int API dw_init(int newthread, int argc, char *argv[]);
 #ifdef DW_INCLUDE_DEPRECATED_RESOURCES
 int API dw_int_init(DWResources *res, int newthread, int *argc, char **argv[]);
 #define dw_init(a, b, c) dw_int_init(&_resources, a, &b, &c)
-#else
-int API dw_init(int newthread, int argc, char *argv[]);
 #endif
 void API dw_main(void);
 void API dw_main_quit(void);
--- a/gtk/dw.c	Sun Nov 29 05:29:11 2020 +0000
+++ b/gtk/dw.c	Sun Nov 29 08:31:47 2020 +0000
@@ -1864,7 +1864,7 @@
 {
 #if GLIB_CHECK_VERSION(2,32,0)
    char resource_path[201] = {0};
-   snprintf(resource_path, 200, "/org/dbsoft/dwindows/%u", rid);
+   snprintf(resource_path, 200, "/org/dbsoft/dwindows/resources/%u.png", rid);
    return gdk_pixbuf_new_from_resource(resource_path, NULL);
 #else
    return NULL;
@@ -2069,22 +2069,12 @@
 }
 #endif
 
-static char * _dw_test_xpm[] = {
-   "1 1 1 1",
-   " 	c None",
-   " "};
-   
-/*
- * Initializes the Dynamic Windows engine.
- * Parameters:
- *           newthread: True if this is the only thread.
- *                      False if there is already a message loop running.
- */
 #ifdef DW_INCLUDE_DEPRECATED_RESOURCES
+#undef dw_init
 int dw_int_init(DWResources *res, int newthread, int *pargc, char **pargv[])
 {
-   int z, argc = pargc ? *pargc : 0;
-   char *fname, **argv = pargv ? *pargv : NULL;
+   int argc = pargc ? *pargc : 0;
+   char **argv = pargv ? *pargv : NULL;
 
    if(res)
    {
@@ -2092,12 +2082,25 @@
       _resources.resource_id = res->resource_id;
       _resources.resource_data = res->resource_data;
    }
-#else
+   return dw_init(newthread, argc, argv);
+}
+#endif
+
+/*
+ * Initializes the Dynamic Windows engine.
+ * Parameters:
+ *           newthread: True if this is the only thread.
+ *                      False if there is already a message loop running.
+ */
 int dw_init(int newthread, int argc, char *argv[])
 {
    int z;
    char *fname;
-#endif
+   static char * _dw_test_xpm[] = {
+      "1 1 1 1",
+      " 	c None",
+      " "};
+   
 
    /* Setup the private data directory */
    if(argc > 0 && argv[0])
--- a/gtk3/dw.c	Sun Nov 29 05:29:11 2020 +0000
+++ b/gtk3/dw.c	Sun Nov 29 08:31:47 2020 +0000
@@ -1924,7 +1924,7 @@
 {
 #if GLIB_CHECK_VERSION(2,32,0)
    char resource_path[201] = {0};
-   snprintf(resource_path, 200, "/org/dbsoft/dwindows/%u", rid);
+   snprintf(resource_path, 200, "/org/dbsoft/dwindows/resources/%u.png", rid);
    return gdk_pixbuf_new_from_resource(resource_path, NULL);
 #else
    return NULL;
@@ -2002,13 +2002,8 @@
 }
 #endif
 
-/*
- * Initializes the Dynamic Windows engine.
- * Parameters:
- *           newthread: True if this is the only thread.
- *                      False if there is already a message loop running.
- */
 #ifdef DW_INCLUDE_DEPRECATED_RESOURCES
+#undef dw_init
 int dw_int_init(DWResources *res, int newthread, int *pargc, char **pargv[])
 {
    int argc = pargc ? *pargc : 0;
@@ -2020,10 +2015,18 @@
       _resources.resource_id = res->resource_id;
       _resources.resource_data = res->resource_data;
    }
-#else
+   return dw_init(newthread, argc, argv);
+}
+#endif
+
+/*
+ * Initializes the Dynamic Windows engine.
+ * Parameters:
+ *           newthread: True if this is the only thread.
+ *                      False if there is already a message loop running.
+ */
 int dw_init(int newthread, int argc, char *argv[])
 {
-#endif
    /* Setup the private data directory */
    if(argc > 0 && argv[0])
    {