Mercurial > dwindows
changeset 1384:156e32814c83
Cleanup of the previous commits and added Unix support.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 25 Nov 2011 18:31:54 +0000 |
parents | ead81c3d9e4e |
children | fc20ad815428 |
files | dw.h gtk/dw.c gtk3/dw.c mac/dw.m os2/dw.c template/dw.c win/dw.c |
diffstat | 7 files changed, 97 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/dw.h Fri Nov 25 17:51:49 2011 +0000 +++ b/dw.h Fri Nov 25 18:31:54 2011 +0000 @@ -1678,6 +1678,7 @@ int API dw_browse(char *url); char * API dw_file_browse(char *title, char *defpath, char *ext, int flags); char * API dw_user_dir(void); +char * API dw_app_dir(void); DWDialog * API dw_dialog_new(void *data); int API dw_dialog_dismiss(DWDialog *dialog, void *result); void * API dw_dialog_wait(DWDialog *dialog);
--- a/gtk/dw.c Fri Nov 25 17:51:49 2011 +0000 +++ b/gtk/dw.c Fri Nov 25 18:31:54 2011 +0000 @@ -135,6 +135,7 @@ GdkBitmap *_dw_tmpbitmap = NULL; char *_DWDefaultFont = NULL; +static char _dw_share_path[PATH_MAX+1] = { 0 }; #if GTK_MAJOR_VERSION < 2 static int _dw_file_active = 0; @@ -2095,6 +2096,37 @@ _resources.resource_id = res->resource_id; _resources.resource_data = res->resource_data; } + + /* Setup the private data directory */ + if(argc && argv && *argc > 0 && (*argv)[0]) + { + char *pathcopy = strdup((*argv)[0]); + char *pos = strrchr(pathcopy, '/'); + + if(pos) + { + char *binname = pos + 1; + + *pos = 0; + if(*binname) + { + char *binpos = strstr(pathcopy, "/bin"); + + if(binpos) + strncpy(_dw_share_path, pathcopy, (size_t)(binpos - pathcopy)); + else + strcpy(_dw_share_path, "/usr/local"); + strcat(_dw_share_path, "/share/"); + strcat(_dw_share_path, binname); + } + } + if(pathcopy) + free(pathcopy); + } + /* If that failed... just get the current directory */ + if(!_dw_share_path[0] && !getcwd(_dw_share_path, PATH_MAX)) + _dw_share_path[0] = '/'; + gtk_set_locale(); #if !GLIB_CHECK_VERSION(2,32,0) g_thread_init(NULL); @@ -12541,6 +12573,15 @@ } /* + * Returns a pointer to a static buffer which containes the + * private application data directory. + */ +char * API dw_app_dir(void) +{ + return _dw_share_path; +} + +/* * Call a function from the window (widget)'s context. * Parameters: * handle: Window handle of the widget.
--- a/gtk3/dw.c Fri Nov 25 17:51:49 2011 +0000 +++ b/gtk3/dw.c Fri Nov 25 18:31:54 2011 +0000 @@ -164,6 +164,7 @@ GObject *_DWObject = NULL; char *_DWDefaultFont = NULL; +static char _dw_share_path[PATH_MAX+1] = { 0 }; typedef struct { @@ -1800,6 +1801,37 @@ _resources.resource_id = res->resource_id; _resources.resource_data = res->resource_data; } + + /* Setup the private data directory */ + if(argc && argv && *argc > 0 && (*argv)[0]) + { + char *pathcopy = strdup((*argv)[0]); + char *pos = strrchr(pathcopy, '/'); + + if(pos) + { + char *binname = pos + 1; + + *pos = 0; + if(*binname) + { + char *binpos = strstr(pathcopy, "/bin"); + + if(binpos) + strncpy(_dw_share_path, pathcopy, (size_t)(binpos - pathcopy)); + else + strcpy(_dw_share_path, "/usr/local"); + strcat(_dw_share_path, "/share/"); + strcat(_dw_share_path, binname); + } + } + if(pathcopy) + free(pathcopy); + } + /* If that failed... just get the current directory */ + if(!_dw_share_path[0] && !getcwd(_dw_share_path, PATH_MAX)) + _dw_share_path[0] = '/'; + #if !GLIB_CHECK_VERSION(2,32,0) g_thread_init(NULL); #endif @@ -10350,6 +10382,15 @@ } /* + * Returns a pointer to a static buffer which containes the + * private application data directory. + */ +char * API dw_app_dir(void) +{ + return _dw_share_path; +} + +/* * Call a function from the window (widget)'s context. * Parameters: * handle: Window handle of the widget.
--- a/mac/dw.m Fri Nov 25 17:51:49 2011 +0000 +++ b/mac/dw.m Fri Nov 25 18:31:54 2011 +0000 @@ -3051,7 +3051,7 @@ * Returns a pointer to a static buffer which containes the * private application data directory. */ -char *dw_app_dir(void) +char * API dw_app_dir(void) { return _dw_bundle_path; }
--- a/os2/dw.c Fri Nov 25 17:51:49 2011 +0000 +++ b/os2/dw.c Fri Nov 25 18:31:54 2011 +0000 @@ -11172,7 +11172,7 @@ * Returns a pointer to a static buffer which containes the * private application data directory. */ -char *dw_app_dir(void) +char * API dw_app_dir(void) { return _dw_exec_dir; }
--- a/template/dw.c Fri Nov 25 17:51:49 2011 +0000 +++ b/template/dw.c Fri Nov 25 18:31:54 2011 +0000 @@ -463,7 +463,7 @@ * current user directory. Or the root directory if it could * not be determined. */ -char *dw_user_dir(void) +char * API dw_app_dir(void) { static char _user_dir[1024] = ""; @@ -480,6 +480,16 @@ } /* + * Returns a pointer to a static buffer which containes the + * private application data directory. + */ +char *dw_app_dir(void) +{ + static _dw_app_dir[MAX_PATH+1] = "/"; + return _dw_app_dir; +} + +/* * Displays a debug message on the console... * Parameters: * format: printf style format string.