comparison gtk3/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 bad3e17ab6e5
children fd1de4e9e542
comparison
equal deleted inserted replaced
1383:ead81c3d9e4e 1384:156e32814c83
162 WEBKIT_API WebKitWebFrame *(*_webkit_web_view_get_focused_frame)(WebKitWebView *) = NULL; 162 WEBKIT_API WebKitWebFrame *(*_webkit_web_view_get_focused_frame)(WebKitWebView *) = NULL;
163 #endif 163 #endif
164 164
165 GObject *_DWObject = NULL; 165 GObject *_DWObject = NULL;
166 char *_DWDefaultFont = NULL; 166 char *_DWDefaultFont = NULL;
167 static char _dw_share_path[PATH_MAX+1] = { 0 };
167 168
168 typedef struct 169 typedef struct
169 { 170 {
170 void *func; 171 void *func;
171 char name[30]; 172 char name[30];
1798 { 1799 {
1799 _resources.resource_max = res->resource_max; 1800 _resources.resource_max = res->resource_max;
1800 _resources.resource_id = res->resource_id; 1801 _resources.resource_id = res->resource_id;
1801 _resources.resource_data = res->resource_data; 1802 _resources.resource_data = res->resource_data;
1802 } 1803 }
1804
1805 /* Setup the private data directory */
1806 if(argc && argv && *argc > 0 && (*argv)[0])
1807 {
1808 char *pathcopy = strdup((*argv)[0]);
1809 char *pos = strrchr(pathcopy, '/');
1810
1811 if(pos)
1812 {
1813 char *binname = pos + 1;
1814
1815 *pos = 0;
1816 if(*binname)
1817 {
1818 char *binpos = strstr(pathcopy, "/bin");
1819
1820 if(binpos)
1821 strncpy(_dw_share_path, pathcopy, (size_t)(binpos - pathcopy));
1822 else
1823 strcpy(_dw_share_path, "/usr/local");
1824 strcat(_dw_share_path, "/share/");
1825 strcat(_dw_share_path, binname);
1826 }
1827 }
1828 if(pathcopy)
1829 free(pathcopy);
1830 }
1831 /* If that failed... just get the current directory */
1832 if(!_dw_share_path[0] && !getcwd(_dw_share_path, PATH_MAX))
1833 _dw_share_path[0] = '/';
1834
1803 #if !GLIB_CHECK_VERSION(2,32,0) 1835 #if !GLIB_CHECK_VERSION(2,32,0)
1804 g_thread_init(NULL); 1836 g_thread_init(NULL);
1805 #endif 1837 #endif
1806 gdk_threads_init(); 1838 gdk_threads_init();
1807 1839
10348 } 10380 }
10349 return _user_dir; 10381 return _user_dir;
10350 } 10382 }
10351 10383
10352 /* 10384 /*
10385 * Returns a pointer to a static buffer which containes the
10386 * private application data directory.
10387 */
10388 char * API dw_app_dir(void)
10389 {
10390 return _dw_share_path;
10391 }
10392
10393 /*
10353 * Call a function from the window (widget)'s context. 10394 * Call a function from the window (widget)'s context.
10354 * Parameters: 10395 * Parameters:
10355 * handle: Window handle of the widget. 10396 * handle: Window handle of the widget.
10356 * function: Function pointer to be called. 10397 * function: Function pointer to be called.
10357 * data: Pointer to the data to be passed to the function. 10398 * data: Pointer to the data to be passed to the function.