[misc] simplify the declaration of extensions for FileDialog()

* Also update the Changelog
This commit is contained in:
Pete Batard 2014-05-22 22:46:36 +01:00
parent abae44f198
commit 1e121d2025
5 changed files with 46 additions and 31 deletions

View file

@ -766,10 +766,7 @@ BOOL CALLBACK LogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
long lfHeight;
DWORD log_size;
char *log_buffer = NULL, *filepath;
const char* log_x[] = { "*.log" };
const char* log_d[] = { lmprintf(MSG_108) };
ext_t log_ext = {ARRAYSIZE(log_x), "rufus.log", log_x, log_d };
EXT_DECL(log_ext, "rufus.log", __VA_GROUP__("*.log"), __VA_GROUP__("Rufus log"));
switch (message) {
case WM_INITDIALOG:
apply_localization(IDD_LOG, hDlg);
@ -1509,12 +1506,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
static MY_SHChangeNotifyEntry NotifyEntry;
loc_cmd* lcmd = NULL;
// TODO: Add "*.img;*.vhd" / "All Supported Images" to the list below and use a generic "%s Image" in the .loc
const char* img_x[] = { "*.img", "*.vhd" };
const char* img_d[] = { lmprintf(MSG_095), "VHD Image" };
ext_t img_ext = {ARRAYSIZE(img_x), NULL, img_x, img_d};
const char* iso_x[] = { "*.iso" };
const char* iso_d[] = { lmprintf(MSG_036) };
ext_t iso_ext = {ARRAYSIZE(iso_x), NULL, iso_x, iso_d };
EXT_DECL(img_ext, NULL, __VA_GROUP__("*.img", "*.vhd"), __VA_GROUP__(lmprintf(MSG_095), "VHD Image"));
EXT_DECL(iso_ext, NULL, __VA_GROUP__("*.iso"), __VA_GROUP__(lmprintf(MSG_036)));
switch (message) {

View file

@ -263,6 +263,29 @@ typedef struct {
char* release_notes;
} RUFUS_UPDATE;
/*
* Structure and macros used for the extensions specification of FileDialog()
* You can use:
* EXT_DECL(my_extensions, "default.std", __VA_GROUP__("*.std", "*.other"), __VA_GROUP__("Standard type", "Other Type"));
* to define an 'ext_t my_extensions' variable initialized with the relevant attributes.
*/
typedef struct ext_t {
const size_t count;
const char* filename;
const char** extension;
const char** description;
} ext_t;
#ifndef __VA_GROUP__
#define __VA_GROUP__(...) __VA_ARGS__
#endif
#define EXT_X(prefix, ...) const char* _##prefix##_x[] = { __VA_ARGS__ }
#define EXT_D(prefix, ...) const char* _##prefix##_d[] = { __VA_ARGS__ }
#define EXT_DECL(var, filename, extensions, descriptions) \
EXT_X(var, extensions); \
EXT_D(var, descriptions); \
ext_t var = { ARRAYSIZE(_##var##_x), filename, _##var##_x, _##var##_d }
/* Duplication of the TBPFLAG enum for Windows 7 taskbar progress */
typedef enum TASKBAR_PROGRESS_FLAGS
{
@ -286,14 +309,6 @@ enum WindowsVersion {
WINDOWS_MAX
};
/* Extensions structure used by FileDialog() */
typedef struct ext_t {
const size_t count;
const char* filename;
const char** extension;
const char** description;
} ext_t;
/*
* Globals
@ -375,14 +390,12 @@ extern BOOL WimExtractFile(const char* wim_image, int index, const char* src, co
extern BOOL IsHDImage(const char* path);
extern int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid);
static __inline BOOL UnlockDrive(HANDLE hDrive)
{
static __inline BOOL UnlockDrive(HANDLE hDrive) {
DWORD size;
return DeviceIoControl(hDrive, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL);
}
static __inline void *_reallocf(void *ptr, size_t size)
{
static __inline void *_reallocf(void *ptr, size_t size) {
void *ret = realloc(ptr, size);
if (!ret)
free(ptr);

View file

@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rufus 1.4.8.482"
CAPTION "Rufus 1.4.8.483"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -165,7 +165,7 @@ END
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
CAPTION "Rufus 1.4.8.482"
CAPTION "Rufus 1.4.8.483"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -427,8 +427,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,8,482
PRODUCTVERSION 1,4,8,482
FILEVERSION 1,4,8,483
PRODUCTVERSION 1,4,8,483
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -445,13 +445,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.4.8.482"
VALUE "FileVersion", "1.4.8.483"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.4.8.482"
VALUE "ProductVersion", "1.4.8.483"
END
END
BLOCK "VarFileInfo"

View file

@ -1187,9 +1187,7 @@ INT_PTR CALLBACK NewVersionCallback(HWND hDlg, UINT message, WPARAM wParam, LPAR
STARTUPINFOA si;
PROCESS_INFORMATION pi;
HFONT hyperlink_font = NULL;
const char* dl_x[] = { "*.exe" };
const char* dl_d[] = { lmprintf(MSG_037) };
ext_t dl_ext = { ARRAYSIZE(dl_x), "rufus.log", dl_x, dl_d };
EXT_DECL(dl_ext, NULL, __VA_GROUP__("*.exe"), __VA_GROUP__(lmprintf(MSG_037)));
switch (message) {
case WM_INITDIALOG: