winefile space display
Martin Fuchs
martin-fuchs at gmx.net
Sat May 14 03:51:37 CDT 2005
Please use this version, not that from my other email address.
Changelog:
display free and total disk space in status bar
Index: resource.h
===================================================================
RCS file: /home/wine/wine/programs/winefile/resource.h,v
retrieving revision 1.6
diff -u -p -d -r1.6 resource.h
--- resource.h 21 Oct 2004 19:51:31 -0000 1.6
+++ resource.h 13 May 2005 19:57:36 -0000
@@ -94,6 +97,8 @@
#define IDS_COL_LINKS 1216
#define IDS_COL_ATTR 1217
#define IDS_COL_SEC 1218
+
+#define IDS_FREE_SPACE_FMT 1219
/* range for drive bar command ids: 0x9000..0x90FF */
#ifdef __WINE__
Index: winefile.c
===================================================================
RCS file: /home/wine/wine/programs/winefile/winefile.c,v
retrieving revision 1.34
diff -u -p -d -r1.34 winefile.c
--- winefile.c 11 May 2005 18:23:30 -0000 1.34
+++ winefile.c 13 May 2005 20:02:37 -0000
@@ -2347,6 +2382,40 @@ static int insert_entries(Pane* pane, En
}
+static void format_bytes(LPTSTR buffer, LONGLONG bytes)
+{
+ const static TCHAR sFmtGB[] = {'%', '.', '1', 'f', ' ', 'G', 'B', '\0'};
+ const static TCHAR sFmtMB[] = {'%', '.', '1', 'f', ' ', 'M', 'B', '\0'};
+ const static TCHAR sFmtkB[] = {'%', '.', '1', 'f', ' ', 'k', 'B', '\0'};
+
+ float fBytes = (float)bytes;
+
+ if (bytes >= 1073741824) /* 1 GB */
+ _stprintf(buffer, sFmtGB, fBytes/1073741824.f+.5f);
+ else if (bytes >= 1048576) /* 1 MB */
+ _stprintf(buffer, sFmtMB, fBytes/1048576.f+.5f);
+ else if (bytes >= 1024) /* 1 kB */
+ _stprintf(buffer, sFmtkB, fBytes/1024.f+.5f);
+ else
+ _stprintf(buffer, sLongNumFmt, bytes);
+}
+
+static void set_space_status()
+{
+ ULARGE_INTEGER ulFreeBytesToCaller, ulTotalBytes, ulFreeBytes;
+ TCHAR fmt[64], b1[64], b2[64], buffer[BUFFER_LEN];
+
+ if (GetDiskFreeSpaceEx(NULL, &ulFreeBytesToCaller, &ulTotalBytes, &ulFreeBytes)) {
+ format_bytes(b1, ulFreeBytesToCaller.QuadPart);
+ format_bytes(b2, ulTotalBytes.QuadPart);
+ _stprintf(buffer, RS(fmt,IDS_FREE_SPACE_FMT), b1, b2);
+ } else
+ _tcscpy(buffer, sQMarks);
+
+ SendMessage(Globals.hstatusbar, SB_SETTEXT, 0, (LPARAM)buffer);
+}
+
+
static WNDPROC g_orgTreeWndProc;
static void create_tree_window(HWND parent, Pane* pane, int id, int id_header)
@@ -3201,7 +3270,8 @@ static void set_curdir(ChildWnd* child,
SetWindowText(child->hwnd, path);
if (path[0])
- SetCurrentDirectory(path);
+ if (SetCurrentDirectory(path))
+ set_space_status();
}
@@ -3619,6 +3689,8 @@ LRESULT CALLBACK ChildWndProc(HWND hwnd,
case WM_SETFOCUS:
SetCurrentDirectory(child->path);
+ if (SetCurrentDirectory(child->path))
+ set_space_status();
SetFocus(child->focus_pane? child->right.hwnd: child->left.hwnd);
break;
Index: De.rc
===================================================================
RCS file: /home/wine/wine/programs/winefile/De.rc,v
retrieving revision 1.5
diff -u -p -d -r1.5 De.rc
--- De.rc 23 Feb 2005 20:58:09 -0000 1.5
+++ De.rc 13 May 2005 20:16:58 -0000
@@ -209,4 +209,6 @@ STRINGTABLE
IDS_COL_LINKS "Links"
IDS_COL_ATTR "Attribute"
IDS_COL_SEC "Sicherheit"
+
+ IDS_FREE_SPACE_FMT "%s von %s frei"
}
Index: En.rc
===================================================================
RCS file: /home/wine/wine/programs/winefile/En.rc,v
retrieving revision 1.10
diff -u -p -d -r1.10 En.rc
--- En.rc 21 Nov 2004 15:49:24 -0000 1.10
+++ En.rc 13 May 2005 20:17:15 -0000
@@ -209,4 +209,5 @@ STRINGTABLE
IDS_COL_LINKS "Links"
IDS_COL_ATTR "Attributes"
IDS_COL_SEC "Security"
+ IDS_FREE_SPACE_FMT "%s of %s free"
}
More information about the wine-patches
mailing list