Beispiel #1
0
static void ShowContents(HWND hwnd, char *image_name)
{
    image_contents_t *image;
    image_contents_screencode_t *line;
    image_contents_screencode_t *lines;

    //
    // delete listbox contents
    //
    const HWND hwnd2 = WinWindowFromID(hwnd, DID_CONTENTS_LB);

    LboxFreeContents(hwnd2);

    //
    // don't call the all the vice stuff if file doesn't exist
    //
    if (!util_file_exists(image_name)) {
        return;
    }

    //
    // try to open as a disk or tape image
    //
    image = diskcontents_read(image_name, 0);
    if (!image) {
        return;
    }

    //
    // set the wanted font
    //
    WinSendMsg(hwnd2, LM_SETITEMHEIGHT, (MPARAM)9, 0);

    //
    // convert image contents to screencodes
    //
    lines = image_contents_to_screencode(image);

    //
    // Loop over all entries
    //
    {
        int idx = 0;

        line = lines;
        do {
            WinInsertLboxItem(hwnd2, LIT_END, "");
            WinLboxSetItemHandle(hwnd2, idx, (long)line);
            WinSetLboxItemText(hwnd2, idx, "");
            idx++;
        } while ((line = line->next));
    }

    //
    // free image structure
    //
    image_contents_destroy(image);
}
Beispiel #2
0
VOID MP3DISPLAY :: RenameAll (VOID)
{
#ifdef _DEBUGLOG_
    fputs ("\nRenameAll ()\n", pfileLog);
#endif

    if (! hwnd || ! FilesInList ())
        return;

/*    // confirm operation
    if (WinMessageBox (HWND_DESKTOP, hwnd,
#ifdef _MULTILANGUAGES_
                       RSTR (IDS_REALLYRENAMEALL),
                       RSTR (IDS_REALLYRENAMEALLHEADING),
#else
                       "Rename all files (with tag) to their Title?",
                       "REALLY RENAME?",
#endif
                       0L,
                       MB_OKCANCEL | MB_QUERY | MB_DEFBUTTON2 | MB_MOVEABLE)
        != MBID_OK)
        return; */

    if (QueryMP3 ())
    {
        delete QueryMP3 ();
        SetMP3 (NULL);
    }

    // set mouse-ptr to "wait" shape
    HPOINTER   hptr = WinQueryPointer (HWND_DESKTOP);
    WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP, SPTR_WAIT,
                                                     FALSE));
    // do the thing
    CHAR    ach[_MAX_PATH], ach2[_MAX_PATH+31];
    ULONG   c = 0L;

    // FIXME perhaps ... = strlen ("Filename");
    plist->usMaxLen[TAG_FILENAME] = 0;

    for (ULONG i = 0; i < CountFilesInList (); i++)
    {
        QueryFile (ach, sizeof (ach), i);

        if ((pmp3 = new MP3 (ach)))
        {
//            if (pmp3->IsTagged ())
            {
#ifdef _MULTILANGUAGES_
                sprintf (ach2, RSTR (IDS_RENAMINGFORMAT), ach);
#else
                sprintf (ach2, "Renaming - %s", ach);
#endif
                WinSetWindowText (hwnd, ach2);

                USHORT  cb = GETSETTINGS->QueryLong (SEI_RENAMELENGTH);
                if (! GETSETTINGS->QueryFlag (SEI_RENAMELIMITLENGTH))
                    cb = 0;
                if (pren->Rename (pmp3,
                            GETSETTINGS->QueryString (SEI_RENAMETEMPLATE),
                            GETSETTINGS->QueryFlag (SEI_RENAMEREPLACESPACES),
                            cb))
                {
                    c ++;
                    strcpy (ach2, pmp3->QueryFilename ().c_str ());
                    WinSetLboxItemText (WinWindowFromID (hwnd, WID_DDL_FILES),
                                        i, ach2);
                    WinSendDlgItemMsg (hwnd, WID_DDL_FILES, EM_SETFIRSTCHAR,
                                       0L, 0L);
                    // if this MP3's filename is longer than current maximum
                    // in list adjust maximum (needed for outputing lists)
                    plist->usMaxLen[TAG_FILENAME] =
                        max (plist->usMaxLen[TAG_FILENAME],
                             USHORT (strlen (pmp3->QueryFilename ().c_str ())));
                }
                else
                {
#ifdef _MULTILANGUAGES_
                    DisplayError (RSTR (IDS_ERROR_GENERALHEADING),
                                  RSTR (IDS_ERROR_RENAMINGFAILED),
                                  ach, errno);
#else
                    DisplayError ("ERROR", "Renaming file '%s' failed: "
                                  "Error %d.", ach, errno);
#endif
                    plist->usMaxLen[TAG_FILENAME] =
                        max (plist->usMaxLen[TAG_FILENAME],
                             USHORT (strlen (ach)));
                }
            }
            delete pmp3;
        }
    }

    if (pset->NotifyRename ())
    {
#ifdef _MULTILANGUAGES_
        // tell user what has been done
        if (c < CountFilesInList ())
            Notify (RSTR (IDS_FILESRENAMEDHEADING),
                    RSTR (IDS_SOMEFILESRENAMED), c);
        else
            Notify (RSTR (IDS_FILESRENAMEDHEADING),
                    RSTR (IDS_ALLFILESRENAMED));
#else
        // tell user what has been done
        if (c < CountFilesInList ())
            Notify ("SOME FILES RENAMED",
                    "%ld selected files have been renamed (The "
                    "others probably had no tag)", c);
        else
            Notify ("ALL FILES SAVED",
                    "All selected files have been renamed.");
#endif
    }

    // reload the current file and refresh the display
    SetMP3 (NULL);
    Refresh ();

    QueryFile (ach, sizeof (ach));
    WinSetWindowText (WinWindowFromID (hwnd, WID_DDL_FILES), ach);

    // set mouse-ptr to normal shape
    WinSetPointer (HWND_DESKTOP, hptr);
    WinSetWindowText (hwnd, PSZ_NAMEVERSION);
}