Changeset 1125


Ignore:
Timestamp:
Aug 27, 2008, 6:35:43 PM (17 years ago)
Author:
John Small
Message:

Ticket 259: Support saving and restoring a toolbar with DirCnr states.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/cfgmgr.cmd

    r1091 r1125  
    1 /* CFGMGR.CMD - manage installation and deinstallation
    2    of FM/2 configuration files
     1/*
     2        $Id: $
     3       
     4   CFGMGR.CMD - manage installation, maintenance and deinstallation
     5                                 of FM/2 configuration files
    36
    47   Optional Parameters:
    58
    6            /RESET        Forces overwrite of existing configuration
     9           /DEFAULTS     Forces overwrite of existing configuration
    710                   files, i.e. "reset to FM/2 defaults"
    811
     
    2427
    2528n = setlocal()
    26 
     29t = time('e')
    2730signal on novalue                 /* for debugging */
    2831
     
    3033call SysLoadFuncs
    3134
    32 globals = 'cfg.'
     35globals = 'cfg. button.'
    3336
    3437call Init
    35 
    36 /*
    37 call DeleteObsoleteFiles
    38 */
    3938
    4039parse arg args
     
    5857      if file_exists \= '' then
    5958         do
    60             if FilesAreDifferent(cfg.file.f.default, cfg.file.f.name) = 1 then
    61                if cfg.defaults = 1 then
     59            if cfg.defaults = 1 then
     60               if FilesAreDifferent(cfg.file.f.default, cfg.file.f.name) = 1 then
    6261                  do
    63                      call SysMkDir cfg.backupdir
    6462                     if cfg.unattended = 0 then
    6563                        do
     
    7371                     cfg.errorcode = CfgAction( 'RESETTODEFAULT', f )
    7472                  end
     73               else
     74                  nop
     75            else
     76               if (cfg.file.f.toolbar = 1) & (cfg.unattended = 1) then
     77                  call Ticket267Fix cfg.file.f.name
    7578         end
    7679      else
     
    122125say
    123126say cfg.pgmname' has ended.'
     127say 'Time elapsed:' time('e')
    124128n = endlocal()
    125129exit cfg.errorcode
     
    128132Init: procedure expose (globals)
    129133
     134        button.                         = ''
     135       
     136        button.CMDS.helptext = 'Commands toolbar'
     137        button.CMDS.text     = 'Cmds'
     138        button.CMDS.id       = 4900
     139       
     140        button.UTILS.helptext = 'Utility toolbar'
     141        button.UTILS.text     = 'Utils'
     142        button.UTILS.id       = 4901
     143       
     144        button.SORT.helptext = 'Sort toolbar'
     145        button.SORT.text     = 'Sort'
     146        button.SORT.id       = 4902
     147       
     148        button.SELECT.helptext = 'Select toolbar'
     149        button.SELECT.text     = 'Select'
     150        button.SELECT.id       = 4903
     151       
     152        button.CONFIG.helptext = 'Configuration toolbar'
     153        button.CONFIG.text     = 'Cmds'
     154        button.CONFIG.id       = 4904
     155       
     156        button.FILES.helptext = 'Files toolbar'
     157        button.FILES.text     = 'Files'
     158        button.FILES.id       = 4905
     159       
     160        button.VIEWS.helptext = 'Views toolbar'
     161        button.VIEWS.text     = 'Views'
     162        button.VIEWS.id       = 4906
     163       
    130164   cfg.              = ''
    131165   cfg.errorcode     = 0
    132166   cfg.defaults      = 0
    133167   cfg.unattended    = 0
     168   cfg.actionmethod  = 'COPY'       /* The default method of backing up and restoring */
    134169   cfg.backupdir     = '.\User_Config_Backup'
    135    cfg.actionmethod  = 'COPY'       /* The default method of backing up and restoring */
     170
     171   call SysMkDir cfg.backupdir
    136172
    137173   f = 0
     
    144180   cfg.file.f.desc.1  = 'FM/2 associations'
    145181   cfg.file.f.desc.0  = 1
     182   cfg.file.f.toolbar = 0
    146183
    147184   f = f + 1
     
    150187   cfg.file.f.desc.1  = 'FM/2 user-defined commands'
    151188   cfg.file.f.desc.0  = 1
     189   cfg.file.f.toolbar = 0
    152190
    153191   f = f + 1
     
    156194   cfg.file.f.desc.1  = 'FM/2 archiver definitions'
    157195   cfg.file.f.desc.0  = 1
     196   cfg.file.f.toolbar = 0
    158197
    159198   f = f + 1
     
    162201   cfg.file.f.desc.1  = 'FM/2 toolbar: commands'
    163202   cfg.file.f.desc.0  = 1
     203   cfg.file.f.toolbar = 1
    164204
    165205   f = f + 1
     
    168208   cfg.file.f.desc.1  = 'FM/2 toolbar: files'
    169209   cfg.file.f.desc.0  = 1
     210   cfg.file.f.toolbar = 1
    170211
    171212   f = f + 1
     
    174215   cfg.file.f.desc.1  = 'FM/2 toolbar: select'
    175216   cfg.file.f.desc.0  = 1
     217   cfg.file.f.toolbar = 1
    176218
    177219   f = f + 1
     
    180222   cfg.file.f.desc.1  = 'FM/2 toolbar: sort'
    181223   cfg.file.f.desc.0  = 1
     224   cfg.file.f.toolbar = 1
    182225
    183226   f = f + 1
     
    186229   cfg.file.f.desc.1  = 'FM/2 toolbar: utils'
    187230   cfg.file.f.desc.0  = 1
     231   cfg.file.f.toolbar = 1
    188232
    189233   f = f + 1
     
    192236   cfg.file.f.desc.1  = 'FM/2 toolbar: views'
    193237   cfg.file.f.desc.0  = 1
     238   cfg.file.f.toolbar = 1
    194239
    195240   f = f + 1
     
    198243   cfg.file.f.desc.1  = 'FM/2 toolbar: config'
    199244   cfg.file.f.desc.0  = 1
     245   cfg.file.f.toolbar = 1
    200246
    201247   f = f + 1
     
    204250   cfg.file.f.desc.1  = 'FM/2 toolbar: tools?'
    205251   cfg.file.f.desc.0  = 1
     252   cfg.file.f.toolbar = 0
    206253
    207254   f = f + 1
     
    210257   cfg.file.f.desc.1  = 'FM/2 filters'
    211258   cfg.file.f.desc.0  = 1
     259   cfg.file.f.toolbar = 0
    212260
    213261   f = f + 1
     
    216264   cfg.file.f.desc.1  = 'FM/2 toolbar list'
    217265   cfg.file.f.desc.0  = 1
     266   cfg.file.f.toolbar = 0
    218267
    219268   f = f + 1
     
    222271   cfg.file.f.desc.1  = 'FM/2 FAT optimizing command'
    223272   cfg.file.f.desc.0  = 1
     273   cfg.file.f.toolbar = 0
    224274
    225275   f = f + 1
     
    228278   cfg.file.f.desc.1  = 'FM/2 HPFS optimizing command'
    229279   cfg.file.f.desc.0  = 1
     280   cfg.file.f.toolbar = 0
    230281
    231282   f = f + 1
     
    234285   cfg.file.f.desc.1  = 'FM/2 JFS optimizing command'
    235286   cfg.file.f.desc.0  = 1
     287   cfg.file.f.toolbar = 0
    236288
    237289   cfg.file.0         = f
     
    343395   return reply
    344396
    345 /*
    346 DeleteObsoleteFiles: procedure expose (globals)
    347    i  =  0
    348 
    349    i  =  i + 1
    350    Obsolete.i = 'readme.org'
    351 
    352    i  =  i + 1
    353    Obsolete.i = 'install.cmd'
    354 
    355    i  =  i + 1
    356    Obsolete.i = 'install.dat'
    357 
    358    i  =  i + 1
    359    Obsolete.i = 'uninstal.cmd'
    360 
    361    Obsolete.0 = i
    362    do i = 1 to Obsolete.0
    363       call SysFileTree Obsolete.i, 'list.', 'FOS'
    364       do j = 1 to list.0
    365          'del 'list.j
    366       end
    367    end
    368 return
    369 */
    370 
    371397FilesAreDifferent: procedure
    372398   parse arg file.1, file.2
     
    410436return GetResponse(msg '(Y/n)?')
    411437
    412 novalue:
    413    say 'Unitialized variable: 'condition('D')' found on line: 'sigl
    414    say 'Line text: 'sourceline(sigl)
    415    say
    416    say 'Exiting...'
    417    signal NormalExit
    418 
    419 
    420438Usage: procedure expose (globals)
    421439   say 'Proper usage of 'cfg.pgmname':'
     
    438456   say
    439457   say 'The optional parameter /UNATTENDED means there will be NO user interaction'
    440    say '   interaction during or confirmation of the operation!!!'
     458   say '   or confirmation of the operation!!!'
    441459   say 'The order of the parameters is not important.'
    442460return
     
    542560   if EnvVarList = '' | EnvVarList = 'ERROR:' then
    543561      call SysIni inifile, 'FM/3', 'TreeEnvVarList', 'PATH;DPATH;LIBPATH;HELP;BOOKSHELF;LIB;INCLUDE;LOCPATH;SMINCLUDE;LPATH;CODELPATH'
     562   LastToolbox = SysIni(inifile, 'FM/3', 'LastToolBox')
     563   LastToolbar = SysIni(inifile, 'FM/3', 'LastToolbar')
     564   if LastToolbar = 'ERROR:' then
     565      do
     566         if LastToolBox = 'ERROR:' then
     567            LastToolbar = 'CMDS.TLS'
     568         else
     569                LastToolbar = LastToolbox
     570        call SysIni inifile, 'FM/3', 'LastToolbar', LastToolbar
     571      end
     572   if SysIni(inifile, 'FM/3', 'FM2Shudown.Toolbar') = 'ERROR:' then
     573                call SysIni inifile, 'FM/3', 'FM2Shutdown.Toolbar', LastToolbar
    544574return
    545575
     576Ticket267Fix: procedure expose (globals)
     577        parse arg infile
     578        fix_string = 'Fixed: Ticket 267'
     579        abort_fix = 0
     580        outfile = SysTempFilename('cfgmgr??.fix')
     581        call lineout outfile, ';' fix_string
     582        /* Read file, if comment has "already repaired" message then stop */
     583        do while lines(infile) > 0
     584                line = linein(infile)
     585                if left(line, 1) = ';' then
     586                        if pos(fix_string, line) > 0 then
     587                                do
     588                                        abort_fix = 1
     589                                        leave
     590                                end
     591                        else
     592                                call lineout outfile, line
     593                else if word(line, 1) = ':spacer' then
     594                        call lineout outfile, ';' || substr(line, 2)
     595                else
     596                        do
     597                                tool.1 = line
     598                                tool.2 = linein(infile)
     599                                tool.3 = linein(infile)
     600                                tool.4 = linein(infile)
     601                                button_name = translate(tool.2)
     602                                if (button.button_name.text \= '') & (tool.4 >= 4900) & (tool.4 < 4950) then
     603                                        do
     604                                                call lineout outfile, button.button_name.helptext
     605                                                call lineout outfile, button.button_name.text
     606                                                call lineout outfile, tool.3
     607                                                call lineout outfile, button.button_name.id
     608                                        end
     609                                else
     610                                        do
     611                                                call lineout outfile, tool.1
     612                                                call lineout outfile, tool.2
     613                                                call lineout outfile, tool.3
     614                                                call lineout outfile, tool.4
     615                                        end
     616                        end                                     
     617        end
     618        call stream infile, 'c', 'close'
     619        call stream outfile, 'c', 'close'
     620        if abort_fix = 0 then
     621                do
     622         'copy' infile cfg.backupdir         /* backup tls file */
     623                        'copy' outfile infile                   /* "install" new  tls file */
     624                        cfg.action_taken = 1
     625                end
     626        call SysFileDelete outfile
     627return
     628
  • trunk/dll/mainwnd.c

    r1121 r1125  
    107107static BOOL RestoreDirCnrState(HWND hwndClient, PSZ pszStateName, BOOL noview);
    108108static VOID DeletePresParams(PSZ pszKeyroot);
     109static VOID BuildTools(HWND hwndT, BOOL resize);
    109110
    110111static MRESULT EXPENTRY MainObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
     
    12911292                    (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ?
    12921293                    "TRUE" : NULL))
    1293         BuildTools(hwndToolback, TRUE);
     1294        PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    12941295      break;
    12951296    }
     
    14101411}
    14111412
    1412 VOID BuildTools(HWND hwndT, BOOL resize)
     1413static VOID BuildTools(HWND hwndT, BOOL resize)
    14131414{
    14141415  TOOL *tool;
     
    14201421  henum = WinBeginEnumWindows(hwndT);
    14211422  while ((hwndTool = WinGetNextWindow(henum)) != NULLHANDLE)
    1422     WinDestroyWindow(hwndTool);
     1423    if (!WinDestroyWindow(hwndTool))
     1424      Runtime_Error(pszSrcFile, __LINE__, "Unable to destroy toolbar button");
    14231425  WinEndEnumWindows(henum);
    14241426  if (!fToolbar) {
     
    25652567    return 0;
    25662568
     2569  case UM_SETUP2:  /* Used to load a new a toolbar */
     2570    BuildTools(hwnd, TRUE);
     2571    return 0;
     2572
    25672573  case WM_CHORD:
    25682574    {
     
    25842590    if (WinDlgBox(HWND_DESKTOP,
    25852591                  hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
    2586       BuildTools(hwnd, TRUE);
     2592      PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
    25872593    return MRFROMSHORT(TRUE);
    25882594
     
    28322838  fIsShutDownState = strcmp(pszStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0;
    28332839  sprintf(szPrefix, "%s.", pszStateName);
     2840
     2841  sprintf(szKey, "%sToolbar", szPrefix);
     2842  PrfWriteProfileString(fmprof, FM3Str, szKey, lasttoolbar);
    28342843
    28352844  henum = WinBeginEnumWindows(hwndClient);
     
    30593068  fDeleteState = strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)) == 0;
    30603069
     3070  size = (ULONG)0;
     3071  sprintf(szKey, "%sToolbar", szPrefix);
     3072  if (PrfQueryProfileSize(fmprof, FM3Str, szKey, &size) && size)
     3073  {
     3074    if (fToolsChanged)
     3075      save_tools(NULL);
     3076    PrfQueryProfileData(fmprof, FM3Str, szKey, lasttoolbar, &size);
     3077    PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar);
     3078    load_tools(NULL);
     3079    PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
     3080  }
    30613081  size = sizeof(SWP);
    30623082  sprintf(szKey, "%sMySizeLastTime", szPrefix);
     
    51075127    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    51085128                 &fTextTools, TRUE, "TextTools");
    5109     BuildTools(hwndToolback, TRUE);
     5129    PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    51105130    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    51115131            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     
    51155135    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    51165136                 &fToolTitles, TRUE, "ToolTitles");
    5117     BuildTools(hwndToolback, TRUE);
     5137    PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    51185138    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    51195139            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     
    52015221
    52025222  case IDM_CREATETOOL:
    5203     BuildTools(hwndToolback, TRUE);
     5223    PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    52045224    break;
    52055225
     
    52075227    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    52085228                 IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
    5209     BuildTools(hwndToolback, TRUE);
     5229    PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    52105230    WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    52115231                                  MAIN_TOOLS), fToolbar);
     
    53985418            load_tools(NULL);
    53995419          else {
    5400             strcpy(lasttoolbox,
     5420            strcpy(lasttoolbar,
    54015421                   quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
    5402             PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox);
     5422            PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar);
    54035423          }
    5404           BuildTools(hwndToolback, TRUE);
     5424          PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    54055425        }
    54065426      }
     
    57165736     * start up some initial children
    57175737     */
    5718     load_tools(NULL);
    5719     BuildTools(hwndToolback, TRUE);
    57205738    WinShowWindow(WinQueryWindow(hwnd, QW_PARENT), TRUE);
    57215739    PostMsg(MainObjectHwnd, UM_SETUP2, mp1, mp2);
     
    57685786                          SWP_ZORDER | SWP_ACTIVATE);
    57695787      }
    5770       ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5771                                   MAIN_TOOLS));
     5788//       ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     5789//                                MAIN_TOOLS));
    57725790    }
    57735791    PostMsg(MainObjectHwnd, UM_SETUP3, mp1, mp2);
     
    57805798      PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszStatename), MPVOID);
    57815799      if (!add_setup(pszStatename))
    5782               save_setups();
     5800        save_setups();
     5801    } else {
     5802      load_tools(NULL);
     5803      PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    57835804    }
    57845805    PostMsg(MainObjectHwnd, UM_SETUP4, mp1, mp2);
     
    60376058          if (!foundit) {
    60386059            thisone = FALSE;
    6039             p = strrchr(lasttoolbox, '\\');
     6060            p = strrchr(lasttoolbar, '\\');
    60406061            if (!p)
    6041               p = lasttoolbox;
     6062              p = lasttoolbar;
    60426063            else
    60436064              p++;
     
    60626083        priority_bumped();
    60636084      }
    6064       WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT));
     6085      WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBARTEXT));
    60656086    }
    60666087    return 0;
     
    62706291              load_tools(path);
    62716292              PrfWriteProfileString(fmprof,
    6272                                     FM3Str, "LastToolBox", lasttoolbox);
    6273               BuildTools(hwndToolback, TRUE);
    6274               WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT));
     6293                                    FM3Str, "LastToolbar", lasttoolbar);
     6294              PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
     6295              WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBARTEXT));
    62756296            }
    62766297            else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
  • trunk/dll/mainwnd2.c

    r1039 r1125  
    700700          load_tools(NULL);
    701701        else {
    702           strcpy(lasttoolbox,
     702          strcpy(lasttoolbar,
    703703                 quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
    704           PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox);
    705         }
    706         BuildTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    707                                    MAIN_TOOLS), TRUE);
     704          PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar);
     705        }
     706        PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    708707      }
    709708    }
     
    942941      PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
    943942    load_tools(NULL);
    944     BuildTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    945                                MAIN_TOOLS), TRUE);
     943    PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    946944    fRunning = TRUE;
    947945    return 0;
Note: See TracChangeset for help on using the changeset viewer.