comparison gtk/dw.c @ 2127:663467f6eee4

Code cleanup: Add constants to header for dark mode, buffer sizes and Unicode support. Windows and OS/2 can both be built without Unicode support for legacy platforms and apps. Some new Windows features require Unicode (notifications, edge) and Unicode is buggy on OS/2. Can now check if Unicode is supported with the DW_FEATURE_UTF8_UNICODE feature test. Dark mode constants added DW_DARK_MODE_DISABLED/BASIC/FULL/FORCED. Win: Include dw.h in the WinToast glue for the constants, and improve safety in Edge glue.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 28 Jun 2020 20:34:25 +0000
parents c3f088266bcd
children 42f8ad7a89e8
comparison
equal deleted inserted replaced
2126:97839ff3c985 2127:663467f6eee4
122 #if GLIB_CHECK_VERSION(2,28,0) 122 #if GLIB_CHECK_VERSION(2,28,0)
123 GApplication *_DWApp = NULL; 123 GApplication *_DWApp = NULL;
124 #endif 124 #endif
125 char *_DWDefaultFont = NULL; 125 char *_DWDefaultFont = NULL;
126 static char _dw_share_path[PATH_MAX+1] = { 0 }; 126 static char _dw_share_path[PATH_MAX+1] = { 0 };
127 static char _dw_app_id[101] = { 0 }; 127 static char _dw_app_id[_DW_APP_ID_SIZE+1] = { 0 };
128 128
129 #if GTK_MAJOR_VERSION < 2 129 #if GTK_MAJOR_VERSION < 2
130 static int _dw_file_active = 0; 130 static int _dw_file_active = 0;
131 #endif 131 #endif
132 static int _dw_ignore_click = 0, _dw_ignore_expand = 0, _dw_color_active = 0; 132 static int _dw_ignore_click = 0, _dw_ignore_expand = 0, _dw_color_active = 0;
2050 strcat(_dw_share_path, binname); 2050 strcat(_dw_share_path, binname);
2051 #if GLIB_CHECK_VERSION(2,28,0) 2051 #if GLIB_CHECK_VERSION(2,28,0)
2052 if(!_dw_app_id[0]) 2052 if(!_dw_app_id[0])
2053 { 2053 {
2054 /* If we have a binary name, use that for the Application ID instead. */ 2054 /* If we have a binary name, use that for the Application ID instead. */
2055 snprintf(_dw_app_id, 100, "%s.%s", DW_APP_DOMAIN_DEFAULT, binname); 2055 snprintf(_dw_app_id, _DW_APP_ID_SIZE, "%s.%s", DW_APP_DOMAIN_DEFAULT, binname);
2056 } 2056 }
2057 #endif 2057 #endif
2058 } 2058 }
2059 if(pathcopy) 2059 if(pathcopy)
2060 free(pathcopy); 2060 free(pathcopy);
2127 2127
2128 #if GLIB_CHECK_VERSION(2,28,0) 2128 #if GLIB_CHECK_VERSION(2,28,0)
2129 if(!_dw_app_id[0]) 2129 if(!_dw_app_id[0])
2130 { 2130 {
2131 /* Generate an Application ID based on the PID if all else fails. */ 2131 /* Generate an Application ID based on the PID if all else fails. */
2132 snprintf(_dw_app_id, 100, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid()); 2132 snprintf(_dw_app_id, _DW_APP_ID_SIZE, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid());
2133 } 2133 }
2134 2134
2135 /* Initialize the application subsystem on supported versions... 2135 /* Initialize the application subsystem on supported versions...
2136 * we generate an application ID based on the binary name or PID 2136 * we generate an application ID based on the binary name or PID
2137 * instead of passing NULL to enable full application support. 2137 * instead of passing NULL to enable full application support.
13334 int dw_app_id_set(const char *appid, const char *appname) 13334 int dw_app_id_set(const char *appid, const char *appname)
13335 { 13335 {
13336 #if GLIB_CHECK_VERSION(2,28,0) 13336 #if GLIB_CHECK_VERSION(2,28,0)
13337 if(g_application_id_is_valid(appid)) 13337 if(g_application_id_is_valid(appid))
13338 { 13338 {
13339 strncpy(_dw_app_id, appid, 100); 13339 strncpy(_dw_app_id, appid, _DW_APP_ID_SIZE);
13340 return DW_ERROR_NONE; 13340 return DW_ERROR_NONE;
13341 } 13341 }
13342 return DW_ERROR_GENERAL; 13342 return DW_ERROR_GENERAL;
13343 #else 13343 #else
13344 return DW_ERROR_UNKNOWN; 13344 return DW_ERROR_UNKNOWN;
13897 #endif 13897 #endif
13898 #ifdef DW_INCLUDE_DEPRECATED 13898 #ifdef DW_INCLUDE_DEPRECATED
13899 case DW_FEATURE_MDI: 13899 case DW_FEATURE_MDI:
13900 #endif 13900 #endif
13901 case DW_FEATURE_CONTAINER_STRIPE: 13901 case DW_FEATURE_CONTAINER_STRIPE:
13902 case DW_FEATURE_UTF8_UNICODE:
13902 case DW_FEATURE_MLE_WORD_WRAP: 13903 case DW_FEATURE_MLE_WORD_WRAP:
13903 return DW_FEATURE_ENABLED; 13904 return DW_FEATURE_ENABLED;
13904 default: 13905 default:
13905 return DW_FEATURE_UNSUPPORTED; 13906 return DW_FEATURE_UNSUPPORTED;
13906 } 13907 }
13932 #endif 13933 #endif
13933 #ifdef DW_INCLUDE_DEPRECATED 13934 #ifdef DW_INCLUDE_DEPRECATED
13934 case DW_FEATURE_MDI: 13935 case DW_FEATURE_MDI:
13935 #endif 13936 #endif
13936 case DW_FEATURE_CONTAINER_STRIPE: 13937 case DW_FEATURE_CONTAINER_STRIPE:
13938 case DW_FEATURE_UTF8_UNICODE:
13937 case DW_FEATURE_MLE_WORD_WRAP: 13939 case DW_FEATURE_MLE_WORD_WRAP:
13938 return DW_ERROR_GENERAL; 13940 return DW_ERROR_GENERAL;
13939 /* These features are supported and configurable */ 13941 /* These features are supported and configurable */
13940 default: 13942 default:
13941 return DW_FEATURE_UNSUPPORTED; 13943 return DW_FEATURE_UNSUPPORTED;