Ticket #7289: 0014-Tracker-Add-attr-public_name-localization.patch

File 0014-Tracker-Add-attr-public_name-localization.patch, 8.2 KB (added by mt, 3 years ago)
  • src/kits/tracker/TrackerInitialState.cpp

    From c3ccefbae724cbc2688adbb26902cf4da010e1ca Mon Sep 17 00:00:00 2001
    From: Murai Takashi <tmurai01@gmail.com>
    Date: Mon, 2 Aug 2021 05:11:49 +0900
    Subject: [PATCH 14/14] Tracker: Add attr:public_name localization.
    
    may fix #7289
    
    Change-Id: Iaf930d8ff281e1a4dba966a5dd86221ecf277b51
    ---
     src/kits/tracker/TrackerInitialState.cpp | 129 ++++++++++++++---------
     1 file changed, 77 insertions(+), 52 deletions(-)
    
    diff --git a/src/kits/tracker/TrackerInitialState.cpp b/src/kits/tracker/TrackerInitialState.cpp
    index e78aefa6e5..5d9dcfa55c 100644
    a b ExtraAttributeLazyInstaller::AddExtraAttribute(const char* publicName,  
    160160    const char* name, uint32 type, bool viewable, bool editable, float width,
    161161    int32 alignment, bool extra)
    162162{
    163     for (int32 index = 0; ; index++) {
    164         const char* oldPublicName;
     163    bool hasPublicName = false;
     164    int32 index;
     165    for (index = 0; ; index++) {
     166        const char* oldPublicName = NULL;
    165167        if (fExtraAttrs.FindString("attr:public_name", index, &oldPublicName)
    166168                != B_OK) {
    167169            break;
    168170        }
    169171
    170         if (strcmp(oldPublicName, publicName) == 0)
     172        if (strcmp(oldPublicName, publicName) == 0) {
    171173            // already got this extra atribute, no work left
    172174            return false;
     175        }
     176
     177        const char* oldName = NULL;
     178        fExtraAttrs.FindString("attr:name", index, &oldName);
     179
     180        if (strcmp(oldName, name) == 0 ) {
     181            // in case attr:public_name changed by Locale preflet
     182            // (changes will be applyed after reboot).
     183            // attr:public_name is reset at each startup, so user cannot
     184            // change it directly (i.e. by Filetype preference).
     185            hasPublicName = true;
     186            break;
     187        }
     188
    173189    }
    174190
    175     fExtraAttrs.AddString("attr:public_name", publicName);
    176     fExtraAttrs.AddString("attr:name", name);
    177     fExtraAttrs.AddInt32("attr:type", (int32)type);
    178     fExtraAttrs.AddBool("attr:viewable", viewable);
    179     fExtraAttrs.AddBool("attr:editable", editable);
    180     fExtraAttrs.AddInt32("attr:width", (int32)width);
    181     fExtraAttrs.AddInt32("attr:alignment", alignment);
    182     fExtraAttrs.AddBool("attr:extra", extra);
     191    if (hasPublicName) {
     192        fExtraAttrs.ReplaceString("attr:public_name", index, publicName);
     193    } else {
     194        fExtraAttrs.AddString("attr:public_name", publicName);
     195        fExtraAttrs.AddString("attr:name", name);
     196        fExtraAttrs.AddInt32("attr:type", (int32)type);
     197        fExtraAttrs.AddBool("attr:viewable", viewable);
     198        fExtraAttrs.AddBool("attr:editable", editable);
     199        fExtraAttrs.AddInt32("attr:width", (int32)width);
     200        fExtraAttrs.AddInt32("attr:alignment", alignment);
     201        fExtraAttrs.AddBool("attr:extra", extra);
     202    }
    183203
    184204    fDirty = true;
    185205    return true;
    TTracker::InitMimeTypes()  
    341361        // install a couple of extra fields for bookmark
    342362
    343363        ExtraAttributeLazyInstaller installer(B_BOOKMARK_MIMETYPE);
    344         installer.AddExtraAttribute("URL", "META:url", B_STRING_TYPE,
    345             true, true, 170, B_ALIGN_LEFT, false);
    346         installer.AddExtraAttribute("Keywords", "META:keyw", B_STRING_TYPE,
    347             true, true, 130, B_ALIGN_LEFT, false);
    348         installer.AddExtraAttribute("Title", "META:title", B_STRING_TYPE,
    349             true, true, 130, B_ALIGN_LEFT, false);
     364        installer.AddExtraAttribute(B_TRANSLATE("URL"), "META:url",
     365            B_STRING_TYPE, true, true, 170, B_ALIGN_LEFT, false);
     366        installer.AddExtraAttribute(B_TRANSLATE("Keywords"), "META:keyw",
     367            B_STRING_TYPE, true, true, 130, B_ALIGN_LEFT, false);
     368        installer.AddExtraAttribute(B_TRANSLATE("Title"), "META:title",
     369            B_STRING_TYPE, true, true, 130, B_ALIGN_LEFT, false);
    350370    }
    351371
    352372    InstallMimeIfNeeded(B_PERSON_MIMETYPE, R_PersonIcon,
    TTracker::InitMimeTypes()  
    354374
    355375    {
    356376        ExtraAttributeLazyInstaller installer(B_PERSON_MIMETYPE);
    357         installer.AddExtraAttribute("Contact name", kAttrName, B_STRING_TYPE,
    358             true, true, 120, B_ALIGN_LEFT, false);
    359         installer.AddExtraAttribute("Company", kAttrCompany, B_STRING_TYPE,
    360             true, true, 120, B_ALIGN_LEFT, false);
    361         installer.AddExtraAttribute("Address", kAttrAddress, B_STRING_TYPE,
    362             true, true, 120, B_ALIGN_LEFT, false);
    363         installer.AddExtraAttribute("City", kAttrCity, B_STRING_TYPE,
    364             true, true, 90, B_ALIGN_LEFT, false);
    365         installer.AddExtraAttribute("State", kAttrState, B_STRING_TYPE,
    366             true, true, 50, B_ALIGN_LEFT, false);
    367         installer.AddExtraAttribute("Zip", kAttrZip, B_STRING_TYPE,
    368             true, true, 50, B_ALIGN_LEFT, false);
    369         installer.AddExtraAttribute("Country", kAttrCountry, B_STRING_TYPE,
    370             true, true, 120, B_ALIGN_LEFT, false);
    371         installer.AddExtraAttribute("E-mail", kAttrEmail, B_STRING_TYPE,
    372             true, true, 120, B_ALIGN_LEFT, false);
    373         installer.AddExtraAttribute("Home phone", kAttrHomePhone,
     377        installer.AddExtraAttribute(B_TRANSLATE("Contact name"), kAttrName,
     378            B_STRING_TYPE, true, true, 120, B_ALIGN_LEFT, false);
     379        installer.AddExtraAttribute(B_TRANSLATE("Company"), kAttrCompany,
     380            B_STRING_TYPE, true, true, 120, B_ALIGN_LEFT, false);
     381        installer.AddExtraAttribute(B_TRANSLATE("Address"), kAttrAddress,
     382            B_STRING_TYPE, true, true, 120, B_ALIGN_LEFT, false);
     383        installer.AddExtraAttribute(B_TRANSLATE("City"), kAttrCity,
    374384            B_STRING_TYPE, true, true, 90, B_ALIGN_LEFT, false);
    375         installer.AddExtraAttribute("Mobile phone", kAttrMobilePhone,
     385        installer.AddExtraAttribute(B_TRANSLATE("State"), kAttrState,
     386            B_STRING_TYPE, true, true, 50, B_ALIGN_LEFT, false);
     387        installer.AddExtraAttribute(B_TRANSLATE("Zip"), kAttrZip,
     388            B_STRING_TYPE, true, true, 50, B_ALIGN_LEFT, false);
     389        installer.AddExtraAttribute(B_TRANSLATE("Country"), kAttrCountry,
     390            B_STRING_TYPE, true, true, 120, B_ALIGN_LEFT, false);
     391        installer.AddExtraAttribute(B_TRANSLATE("E-mail"), kAttrEmail,
     392            B_STRING_TYPE, true, true, 120, B_ALIGN_LEFT, false);
     393        installer.AddExtraAttribute(B_TRANSLATE("Home phone"), kAttrHomePhone,
    376394            B_STRING_TYPE, true, true, 90, B_ALIGN_LEFT, false);
    377         installer.AddExtraAttribute("Work phone", kAttrWorkPhone,
     395        installer.AddExtraAttribute(B_TRANSLATE("Mobile phone"),
     396            kAttrMobilePhone, B_STRING_TYPE, true, true, 90, B_ALIGN_LEFT,
     397            false);
     398        installer.AddExtraAttribute(B_TRANSLATE("Work phone"), kAttrWorkPhone,
    378399            B_STRING_TYPE, true, true, 90, B_ALIGN_LEFT, false);
    379         installer.AddExtraAttribute("Fax", kAttrFax, B_STRING_TYPE,
    380             true, true, 90, B_ALIGN_LEFT, false);
    381         installer.AddExtraAttribute("URL", kAttrURL, B_STRING_TYPE,
    382             true, true, 120, B_ALIGN_LEFT, false);
    383         installer.AddExtraAttribute("Group", kAttrGroup, B_STRING_TYPE,
    384             true, true, 120, B_ALIGN_LEFT, false);
    385         installer.AddExtraAttribute("Nickname", kAttrNickname, B_STRING_TYPE,
    386             true, true, 120, B_ALIGN_LEFT, false);
     400        installer.AddExtraAttribute(B_TRANSLATE("Fax"), kAttrFax,
     401            B_STRING_TYPE, true, true, 90, B_ALIGN_LEFT, false);
     402        installer.AddExtraAttribute(B_TRANSLATE("URL"), kAttrURL,
     403            B_STRING_TYPE, true, true, 120, B_ALIGN_LEFT, false);
     404        installer.AddExtraAttribute(B_TRANSLATE("Group"), kAttrGroup,
     405            B_STRING_TYPE, true, true, 120, B_ALIGN_LEFT, false);
     406        installer.AddExtraAttribute(B_TRANSLATE("Nickname"), kAttrNickname,
     407            B_STRING_TYPE, true, true, 120, B_ALIGN_LEFT, false);
    387408    }
    388409
    389410    InstallMimeIfNeeded(B_PRINTER_SPOOL_MIMETYPE, R_SpoolFileIcon,
    TTracker::InitMimeTypes()  
    406427            B_ALIGN_LEFT, false);
    407428#else
    408429        ExtraAttributeLazyInstaller installer(B_PRINTER_SPOOL_MIMETYPE);
    409         installer.AddExtraAttribute("Page count", "_spool/Page Count",
    410             B_INT32_TYPE, true, false, 40, B_ALIGN_RIGHT, false);
    411         installer.AddExtraAttribute("Description", "_spool/Description",
    412             B_ASCII_TYPE, true, true, 100, B_ALIGN_LEFT, false);
    413         installer.AddExtraAttribute("Printer name", "_spool/Printer",
    414             B_ASCII_TYPE, true, false, 80, B_ALIGN_LEFT, false);
    415         installer.AddExtraAttribute("Job creator type", "_spool/MimeType",
    416             B_ASCII_TYPE, true, false, 60, B_ALIGN_LEFT, false);
     430        installer.AddExtraAttribute(B_TRANSLATE("Page count"),
     431            "_spool/Page Count", B_INT32_TYPE, true, false, 40, B_ALIGN_RIGHT,
     432            false);
     433        installer.AddExtraAttribute(B_TRANSLATE("Description"),
     434            "_spool/Description", B_ASCII_TYPE, true, true, 100, B_ALIGN_LEFT,
     435            false);
     436        installer.AddExtraAttribute(B_TRANSLATE("Printer name"),
     437            "_spool/Printer", B_ASCII_TYPE, true, false, 80, B_ALIGN_LEFT,
     438            false);
     439        installer.AddExtraAttribute(B_TRANSLATE("Job creator type"),
     440            "_spool/MimeType", B_ASCII_TYPE, true, false, 60, B_ALIGN_LEFT,
     441            false);
    417442#endif
    418443    }
    419444