changeset 20245:dcb263f32986

Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling so that Volume names are updated after changing media.
author reimar
date Sun, 15 Oct 2006 18:33:39 +0000
parents 81a514f118d2
children c25a7de1c47c
files Gui/win32/gui.c
diffstat 1 files changed, 21 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/Gui/win32/gui.c	Sun Oct 15 18:27:34 2006 +0000
+++ b/Gui/win32/gui.c	Sun Oct 15 18:33:39 2006 +0000
@@ -843,11 +843,16 @@
             point.y = GET_Y_LPARAM(lParam);
             ClientToScreen(hWnd, &point);
             errmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+            while (GetMenuItemCount(gui->diskmenu) > 0)
+                DeleteMenu(gui->diskmenu, 0, MF_BYPOSITION);
             len = GetLogicalDriveStrings(MAX_PATH, device);
             while(pos < len)
             {
                 if(GetDriveType(device + pos) == DRIVE_CDROM)
                 {
+                    char volname[MAX_PATH];
+                    char menuitem[MAX_PATH];
+                    int flags = MF_STRING;
                     mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] checking %s for CD/VCD/SVCD/DVDs\n", device + pos);
                     sprintf(searchpath, "%sVIDEO_TS", device + pos);
                     sprintf(searchpath2, "%sMpegav", device + pos);
@@ -855,14 +860,26 @@
                     sprintf(searchpath3, "%sTrack01.cda", device + pos);
 #endif
                     if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES)
-                        EnableMenuItem(gui->diskmenu, IDPLAYDISK + cdromdrive, MF_BYCOMMAND | MF_ENABLED);
+                        flags |= MF_ENABLED;
                     else if(GetFileAttributes(searchpath2) != INVALID_FILE_ATTRIBUTES)
-                        EnableMenuItem(gui->diskmenu, IDPLAYDISK + cdromdrive, MF_BYCOMMAND | MF_ENABLED);
+                        flags |= MF_ENABLED;
 #ifdef HAVE_LIBCDIO
                     else if(GetFileAttributes(searchpath3) != INVALID_FILE_ATTRIBUTES)
-                        EnableMenuItem(gui->diskmenu, IDPLAYDISK + cdromdrive, MF_BYCOMMAND | MF_ENABLED);
+                        flags |= MF_ENABLED;
 #endif
-                    else EnableMenuItem(gui->diskmenu, IDPLAYDISK + cdromdrive, MF_BYCOMMAND | MF_GRAYED);
+                    else
+                        flags |= MF_GRAYED;
+                    volname[0] = 0;
+                    strcpy(menuitem, device + pos);
+                    menuitem[strlen(menuitem) - 1]=0;
+                    GetVolumeInformation(device + pos, volname, MAX_PATH, NULL, NULL, NULL, NULL, 0);
+                    if (strlen(volname))
+                    {
+                        capitalize(volname);
+                        strcat(menuitem, " - ");
+                        strcat(menuitem, volname);
+                    }
+                    AppendMenu(gui->diskmenu, flags, IDPLAYDISK + cdromdrive, menuitem);
                         cdromdrive++;
                 }
                 pos += strlen(device + pos) + 1;
@@ -1159,31 +1176,7 @@
 
 static void create_menu(gui_t *gui)
 {
-    char device[MAX_PATH];
-    char volname[MAX_PATH];
-    char menuitem[MAX_PATH];
-    int len, pos = 0, cdromdrive = 0;
     gui->diskmenu = CreatePopupMenu();
-    len = GetLogicalDriveStrings(MAX_PATH, device);
-    while(pos < len)
-    {
-        if(GetDriveType(device + pos) == DRIVE_CDROM)
-        {
-            volname[0] = 0;
-            strcpy(menuitem, device + pos);
-            menuitem[strlen(menuitem) - 1]=0;
-            GetVolumeInformation(device + pos, volname, MAX_PATH, NULL, NULL, NULL, NULL, 0);
-            if (strlen(volname))
-            {
-                capitalize(volname);
-                strcat(menuitem, " - ");
-                strcat(menuitem, volname);
-            }
-            AppendMenu(gui->diskmenu, MF_STRING, IDPLAYDISK + cdromdrive, menuitem);
-            cdromdrive++;
-        }
-        pos += strlen(device + pos) + 1;
-    }
     gui->menu=CreatePopupMenu();
     gui->trayplaymenu = CreatePopupMenu();
     AppendMenu(gui->menu, MF_STRING | MF_POPUP, (UINT) gui->trayplaymenu, "Open...");