Mercurial > dwindows
comparison 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 |
comparison
equal
deleted
inserted
replaced
1383:ead81c3d9e4e | 1384:156e32814c83 |
---|---|
133 GtkWidget *last_window = NULL, *popup = NULL; | 133 GtkWidget *last_window = NULL, *popup = NULL; |
134 GdkPixmap *_dw_tmppixmap = NULL; | 134 GdkPixmap *_dw_tmppixmap = NULL; |
135 GdkBitmap *_dw_tmpbitmap = NULL; | 135 GdkBitmap *_dw_tmpbitmap = NULL; |
136 | 136 |
137 char *_DWDefaultFont = NULL; | 137 char *_DWDefaultFont = NULL; |
138 static char _dw_share_path[PATH_MAX+1] = { 0 }; | |
138 | 139 |
139 #if GTK_MAJOR_VERSION < 2 | 140 #if GTK_MAJOR_VERSION < 2 |
140 static int _dw_file_active = 0; | 141 static int _dw_file_active = 0; |
141 #endif | 142 #endif |
142 static int _dw_ignore_click = 0, _dw_ignore_expand = 0, _dw_color_active = 0; | 143 static int _dw_ignore_click = 0, _dw_ignore_expand = 0, _dw_color_active = 0; |
2093 { | 2094 { |
2094 _resources.resource_max = res->resource_max; | 2095 _resources.resource_max = res->resource_max; |
2095 _resources.resource_id = res->resource_id; | 2096 _resources.resource_id = res->resource_id; |
2096 _resources.resource_data = res->resource_data; | 2097 _resources.resource_data = res->resource_data; |
2097 } | 2098 } |
2099 | |
2100 /* Setup the private data directory */ | |
2101 if(argc && argv && *argc > 0 && (*argv)[0]) | |
2102 { | |
2103 char *pathcopy = strdup((*argv)[0]); | |
2104 char *pos = strrchr(pathcopy, '/'); | |
2105 | |
2106 if(pos) | |
2107 { | |
2108 char *binname = pos + 1; | |
2109 | |
2110 *pos = 0; | |
2111 if(*binname) | |
2112 { | |
2113 char *binpos = strstr(pathcopy, "/bin"); | |
2114 | |
2115 if(binpos) | |
2116 strncpy(_dw_share_path, pathcopy, (size_t)(binpos - pathcopy)); | |
2117 else | |
2118 strcpy(_dw_share_path, "/usr/local"); | |
2119 strcat(_dw_share_path, "/share/"); | |
2120 strcat(_dw_share_path, binname); | |
2121 } | |
2122 } | |
2123 if(pathcopy) | |
2124 free(pathcopy); | |
2125 } | |
2126 /* If that failed... just get the current directory */ | |
2127 if(!_dw_share_path[0] && !getcwd(_dw_share_path, PATH_MAX)) | |
2128 _dw_share_path[0] = '/'; | |
2129 | |
2098 gtk_set_locale(); | 2130 gtk_set_locale(); |
2099 #if !GLIB_CHECK_VERSION(2,32,0) | 2131 #if !GLIB_CHECK_VERSION(2,32,0) |
2100 g_thread_init(NULL); | 2132 g_thread_init(NULL); |
2101 #endif | 2133 #endif |
2102 #if GTK_MAJOR_VERSION > 1 | 2134 #if GTK_MAJOR_VERSION > 1 |
12539 } | 12571 } |
12540 return _user_dir; | 12572 return _user_dir; |
12541 } | 12573 } |
12542 | 12574 |
12543 /* | 12575 /* |
12576 * Returns a pointer to a static buffer which containes the | |
12577 * private application data directory. | |
12578 */ | |
12579 char * API dw_app_dir(void) | |
12580 { | |
12581 return _dw_share_path; | |
12582 } | |
12583 | |
12584 /* | |
12544 * Call a function from the window (widget)'s context. | 12585 * Call a function from the window (widget)'s context. |
12545 * Parameters: | 12586 * Parameters: |
12546 * handle: Window handle of the widget. | 12587 * handle: Window handle of the widget. |
12547 * function: Function pointer to be called. | 12588 * function: Function pointer to be called. |
12548 * data: Pointer to the data to be passed to the function. | 12589 * data: Pointer to the data to be passed to the function. |