Mercurial > dwindows
diff gtk/dw.c @ 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 | d5c1ce21577e |
children | fd1de4e9e542 |
line wrap: on
line diff
--- 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.