1 /*---------------------------------------------------------------------------- 2 -- 3 -- Module: xtmCustArch 4 -- 5 -- Project: XDiary 6 -- System: xtm - X Desktop Calendar 7 -- Subsystem: <> 8 -- Function block: <> 9 -- 10 -- Description: 11 -- Module to handle the archive customization. 12 -- 13 -- Filename: xtmCustArch.c 14 -- 15 -- Authors: Roger Larsson, Ulrika Bornetun 16 -- Creation date: 1991-09-14 17 -- 18 -- 19 -- (C) Copyright Ulrika Bornetun, Roger Larsson (1995) 20 -- All rights reserved 21 -- 22 -- Permission to use, copy, modify, and distribute this software and its 23 -- documentation for any purpose and without fee is hereby granted, 24 -- provided that the above copyright notice appear in all copies. Ulrika 25 -- Bornetun and Roger Larsson make no representations about the usability 26 -- of this software for any purpose. It is provided "as is" without express 27 -- or implied warranty. 28 ----------------------------------------------------------------------------*/ 29 30 /* SCCS module identifier. */ 31 static char SCCSID[] = "@(#) Module: xtmCustArch.c, Version: 1.1, Date: 95/02/18 15:52:01"; 32 33 34 /*---------------------------------------------------------------------------- 35 -- Include files 36 ----------------------------------------------------------------------------*/ 37 38 #include <stdio.h> 39 #include <stdlib.h> 40 #include <string.h> 41 #include <unistd.h> 42 #include <sys/types.h> 43 #include <sys/stat.h> 44 45 #include <X11/Intrinsic.h> 46 47 #include <Xm/Xm.h> 48 #include <Xm/BulletinB.h> 49 #include <Xm/Form.h> 50 #include <Xm/Frame.h> 51 #include <Xm/List.h> 52 #include <Xm/RowColumn.h> 53 #include <Xm/Text.h> 54 55 #include "System.h" 56 #include "LstLinked.h" 57 #include "Message.h" 58 59 #include "msgXdiary.h" 60 #include "xtmGlobal.h" 61 #include "xtmArchive.h" 62 #include "xtmCustom.h" 63 #include "xtmHelp.h" 64 #include "xitError.h" 65 #include "xitTools.h" 66 #include "xtmCustArch.h" 67 68 69 /*---------------------------------------------------------------------------- 70 -- Macro definitions 71 ----------------------------------------------------------------------------*/ 72 73 /* Local widgets in the archive window. */ 74 #define actionRc dataLocalW[ 0 ] 75 #define archLa dataLocalW[ 1 ] 76 #define archLi dataLocalW[ 2 ] 77 #define fileLa dataLocalW[ 3 ] 78 #define fileRc dataLocalW[ 4 ] 79 #define fileTx dataLocalW[ 5 ] 80 #define nameLa dataLocalW[ 6 ] 81 #define nameRc dataLocalW[ 7 ] 82 #define nameTx dataLocalW[ 8 ] 83 84 85 /*---------------------------------------------------------------------------- 86 -- Type declarations 87 ----------------------------------------------------------------------------*/ 88 89 90 /*---------------------------------------------------------------------------- 91 -- Global definitions 92 ----------------------------------------------------------------------------*/ 93 94 /* Name of module. */ 95 static char *module_name = "xtmCustArchive"; 96 97 /* IDs for the help windows. */ 98 static char *cust_arch_window_id = "CustArch"; 99 100 101 /*---------------------------------------------------------------------------- 102 -- Function prototypes 103 ----------------------------------------------------------------------------*/ 104 105 static void 106 archiveListCB( Widget widget, 107 XTM_CU_BASE_DATA_REF appl_data_ref, 108 XmListCallbackStruct *call_data ); 109 110 static void 111 addCB( Widget widget, 112 XTM_CU_BASE_DATA_REF custom_data, 113 XtPointer call_data ); 114 115 static void 116 clearArchCB( void *element ); 117 118 static void 119 deleteCB( Widget widget, 120 XTM_CU_BASE_DATA_REF custom_data, 121 XtPointer call_data ); 122 123 static void 124 helpCB( Widget widget, 125 XTM_CU_BASE_DATA_REF appl_data_ref, 126 XtPointer call_data ); 127 128 static void 129 okCB( Widget widget, 130 XTM_CU_BASE_DATA_REF appl_data_ref, 131 XtPointer call_data ); 132 133 static void 134 setAction( Widget actionW, 135 Boolean add_key, 136 Boolean delete_key ); 137 138 static void 139 setArchiveData( Widget baseW, 140 XTM_CU_BASE_DATA_REF appl_data_ref ); 141 142 143 144 /*---------------------------------------------------------------------------- 145 -- Functions 146 ----------------------------------------------------------------------------*/ 147 148 void xtmCrEditArchiveData(Widget parent,XTM_CU_BASE_DATA_REF appl_data_ref)149 xtmCrEditArchiveData( Widget parent, 150 XTM_CU_BASE_DATA_REF appl_data_ref ) 151 { 152 153 /* Variables. */ 154 int index; 155 Arg args[ 10 ]; 156 Cardinal n; 157 Widget archiveFd; 158 Widget dataFo; 159 Widget dataLocalW[ 9 ]; 160 Widget actionBu[ 2 ]; 161 162 static XIT_PUSH_STRUCT action_def[] = { 163 { "AddPb", "", "", True, NULL }, 164 { "DeletePb", "", "", True, NULL }, 165 }; 166 167 static XIT_TEXT_STRUCT text_buffer[] = { 168 { "NameTx", NULL, 1, True }, 169 { "FileTx", NULL, 1, True }, 170 }; 171 172 static XIT_ACTION_AREA_ITEM action_buttons[] = { 173 { "", okCB, NULL }, 174 { "", NULL, NULL }, 175 { "", helpCB, NULL }, 176 }; 177 178 179 /* Code. */ 180 181 action_buttons[ 0 ].label = msgGetText( MXDI_OK_BUTTON ); 182 action_buttons[ 0 ].data = appl_data_ref; 183 action_buttons[ 1 ].label = msgGetText( MXDI_CANCEL_BUTTON ); 184 action_buttons[ 1 ].data = appl_data_ref; 185 action_buttons[ 2 ].label = msgGetText( MXDI_HELP_BUTTON ); 186 action_buttons[ 2 ].data = appl_data_ref; 187 188 action_def[ 0 ].title = msgGetText( MXDI_ADD_CHANGE_ITEM ); 189 action_def[ 1 ].title = msgGetText( MXDI_DELETE_ITEM ); 190 191 192 /* Create a form dialog with buttons. */ 193 archiveFd = xitCreateFormDialog( parent, "ArchiveFd", 194 1, 0, 195 action_buttons, 196 XtNumber( action_buttons ) ); 197 198 n = 0; 199 XtSetArg( args[ n ], XmNtitle, msgGetText( MXDI_CUST_ARCHIVE_TITLE ) ); n++; 200 XtSetValues( XtParent( archiveFd ), args, n ); 201 202 n = 0; 203 XtSetArg( args[ n ], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); n++; 204 XtSetValues( archiveFd, args, n ); 205 206 207 /* Container for the contents of the window. */ 208 dataFo = XtNameToWidget( archiveFd, "ArchiveFdFo" ); 209 210 211 archLa = xitCreateLabel( dataFo, "ArchLa", 212 msgGetText( MXDI_ARCH_LOCATION_LABEL ), -1 ); 213 214 /* List with database location. */ 215 n = 0; 216 XtSetArg( args[ n ], XmNlistSizePolicy, XmCONSTANT ); n++; 217 XtSetArg( args[ n ], XmNscrollBarDisplayPolicy, XmSTATIC ); n++; 218 XtSetArg( args[ n ], XmNselectionPolicy, XmSINGLE_SELECT ); n++; 219 XtSetArg( args[ n ], XmNlistMarginHeight, 5 ); n++; 220 XtSetArg( args[ n ], XmNlistMarginWidth, 5 ); n++; 221 archLi = XmCreateScrolledList( dataFo, "ArchLi", args, n ); 222 223 XtAddCallback( archLi, XmNsingleSelectionCallback, 224 (XtCallbackProc) archiveListCB, (XtPointer) appl_data_ref ); 225 XtAddCallback( archLi, XmNdefaultActionCallback, 226 (XtCallbackProc) archiveListCB, (XtPointer) appl_data_ref ); 227 228 /* Name of archive file. */ 229 nameRc = XmCreateRowColumn( dataFo, "NameRc", args, 0 ); 230 nameLa = xitCreateLabel( nameRc, "NameLa", 231 msgGetText( MXDI_ARCH_NAME_LABEL ), -1 ); 232 233 nameTx = xitCreateTextCols( nameRc, &text_buffer[ 0 ], 15 ); 234 235 /* Archive file name. */ 236 fileRc = XmCreateRowColumn( dataFo, "FileRc", args, 0 ); 237 238 fileLa = xitCreateLabel( fileRc, "FileLa", 239 msgGetText( MXDI_ARCH_FILE_LABEL ), -1 ); 240 241 fileTx = xitCreateTextCols( fileRc, &text_buffer[ 1 ], 30 ); 242 243 244 /* Set max lengths. */ 245 n = 0; 246 XtSetArg( args[ n ], XmNmaxLength, 15 ); n++; 247 XtSetValues( nameTx, args, n ); 248 249 n = 0; 250 XtSetArg( args[ n ], XmNmaxLength, PATH_MAX ); n++; 251 XtSetValues( fileTx, args, n ); 252 253 254 /* Action (add and delete). */ 255 n = 0; 256 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 257 XtSetArg( args[ n ], XmNspacing, 10 ); n++; 258 XtSetArg( args[ n ], XmNmarginHeight, 10 ); n++; 259 actionRc = XmCreateRowColumn( dataFo, "ActionRc", args, n ); 260 261 for( index = 0; index < XtNumber( actionBu ); index++ ) 262 actionBu[ index ] = xitCreatePushButton( actionRc, 263 &action_def[ index ] ); 264 265 XtAddCallback( actionBu[ 0 ], XmNactivateCallback, 266 (XtCallbackProc) addCB, (XtPointer) appl_data_ref ); 267 XtAddCallback( actionBu[ 1 ], XmNactivateCallback, 268 (XtCallbackProc) deleteCB, (XtPointer) appl_data_ref ); 269 270 271 /* Put the elements together. */ 272 xitAttachWidget( archLa, 273 XmATTACH_FORM, NULL, XmATTACH_FORM, NULL, 274 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 275 xitAttachWidget( XtParent( archLi ), 276 XmATTACH_WIDGET, archLa, XmATTACH_FORM, NULL, 277 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 278 xitAttachWidget( nameRc, 279 XmATTACH_WIDGET, XtParent( archLi ), XmATTACH_FORM, NULL, 280 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 281 xitAttachWidget( fileRc, 282 XmATTACH_WIDGET, nameRc, XmATTACH_FORM, NULL, 283 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 284 xitAttachWidget( actionRc, 285 XmATTACH_WIDGET, fileRc, XmATTACH_FORM, NULL, 286 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 287 288 /* Make sure there is enough space between the children. */ 289 n = 0; 290 XtSetArg( args[ n ], XmNtopOffset, 5 ); n++; 291 XtSetArg( args[ n ], XmNleftOffset, 5 ); n++; 292 XtSetArg( args[ n ], XmNrightOffset, 5 ); n++; 293 XtSetArg( args[ n ], XmNbottomOffset, 5 ); n++; 294 XtSetValues( archLa, args, n ); 295 XtSetValues( XtParent( archLi ), args, n ); 296 XtSetValues( nameRc, args, n ); 297 XtSetValues( fileRc, args, n ); 298 XtSetValues( actionRc, args, n ); 299 300 /* Manage the widgets. */ 301 XtManageChildren( actionBu, XtNumber( actionBu ) ); 302 303 xitManageChildren( dataLocalW, XtNumber( dataLocalW ) ); 304 305 /* Set the size of the window. */ 306 xitSetSizeFormDialog( archiveFd, True ); 307 308 309 /* Make the final attachments. */ 310 xitAttachWidget( actionRc, 311 XmATTACH_NONE, NULL, XmATTACH_FORM, NULL, 312 XmATTACH_NONE, NULL, XmATTACH_FORM, NULL ); 313 xitAttachWidget( fileRc, 314 XmATTACH_NONE, NULL, XmATTACH_FORM, NULL, 315 XmATTACH_NONE, NULL, XmATTACH_WIDGET, actionRc ); 316 xitAttachWidget( nameRc, 317 XmATTACH_NONE, NULL, XmATTACH_FORM, NULL, 318 XmATTACH_NONE, NULL, XmATTACH_WIDGET, fileRc ); 319 xitAttachWidget( XtParent( archLi ), 320 XmATTACH_WIDGET, archLa, XmATTACH_FORM, NULL, 321 XmATTACH_FORM, NULL, XmATTACH_WIDGET, nameRc ); 322 323 324 XtManageChild( archiveFd ); 325 326 327 /* Put defined archive files in the list. */ 328 setArchiveData( archiveFd, appl_data_ref ); 329 setAction( actionRc, True, False ); 330 331 332 return; 333 334 } /* xtmCrEditArchiveData */ 335 336 337 /*----------------------------------------------------------------------*/ 338 339 static void setAction(Widget actionW,Boolean add_key,Boolean delete_key)340 setAction( Widget actionW, 341 Boolean add_key, 342 Boolean delete_key ) 343 { 344 345 /* Variables. */ 346 Widget tempW; 347 348 349 /* Code. */ 350 351 tempW = XtNameToWidget( actionW, "AddPb" ); 352 XtSetSensitive( tempW, add_key ); 353 354 tempW = XtNameToWidget( actionW, "DeletePb" ); 355 XtSetSensitive( tempW, delete_key ); 356 357 return; 358 359 } /* setAction */ 360 361 362 /*----------------------------------------------------------------------*/ 363 364 static void setArchiveData(Widget baseW,XTM_CU_BASE_DATA_REF appl_data_ref)365 setArchiveData( Widget baseW, 366 XTM_CU_BASE_DATA_REF appl_data_ref ) 367 { 368 369 /* Variables. */ 370 int index; 371 int index1; 372 char buffer[ 100 ]; 373 Arg args[ 5 ]; 374 Cardinal n; 375 Widget mainW; 376 Widget tempW; 377 XmString list_items[ 100 ]; 378 LST_STATUS lst_status; 379 XTM_AR_ARCHIVE_FILE archive_file; 380 XTM_GL_CUSTOM_DATA_REF custom_data; 381 382 383 /* Code. */ 384 385 custom_data = appl_data_ref -> custom_data; 386 387 mainW = XtNameToWidget( baseW, "ArchiveFdFo" ); 388 389 /* Set values for the archive files. */ 390 if( LstLinkElements( custom_data -> archive_files ) > 0 ) { 391 392 index = 0; 393 394 lst_status = LstLinkCurrentFirst( custom_data -> archive_files ); 395 while( lst_status == LST_OK ) { 396 397 lst_status = LstLinkGetCurrent( custom_data -> archive_files, 398 &archive_file ); 399 400 sprintf( buffer, "%-15.15s %s", 401 archive_file.short_name, archive_file.file_name ); 402 403 list_items[ index ] = XmStringCreate( buffer, CS ); 404 index++; 405 406 /* Next entry. */ 407 lst_status = LstLinkCurrentNext( custom_data -> archive_files ); 408 409 } /* while */ 410 411 412 /* The list is always sorted. */ 413 xitSortStringList( list_items, index ); 414 415 tempW = XtNameToWidget( mainW, "ArchLiSW.ArchLi" ); 416 417 /* Assign the database locations to the list. */ 418 n = 0; 419 XtSetArg( args[ n ], XmNitems, list_items ); n++; 420 XtSetArg( args[ n ], XmNitemCount, index ); n++; 421 XtSetArg( args[ n ], XmNselectedItemCount, 0 ); n++; 422 XtSetValues( tempW, args, n ); 423 424 /* Free allocated memory. */ 425 for( index1 = 0; index1 < index; index1++ ) 426 XmStringFree( list_items[ index1 ] ); 427 428 } /* if */ 429 430 431 /* Empty the name and directory field. */ 432 tempW = XtNameToWidget( mainW, "NameRc.NameTx" ); 433 XmTextSetString( tempW, "" ); 434 435 tempW = XtNameToWidget( mainW, "FileRc.FileTx" ); 436 XmTextSetString( tempW, "" ); 437 438 return; 439 440 } /* setArchiveData */ 441 442 443 /*----------------------------------------------------------------------*/ 444 445 static void addCB(Widget widget,XTM_CU_BASE_DATA_REF appl_data_ref,XtPointer call_data)446 addCB( Widget widget, 447 XTM_CU_BASE_DATA_REF appl_data_ref, 448 XtPointer call_data ) 449 { 450 451 /* Variables. */ 452 int found_position; 453 int index; 454 int item_count; 455 char buffer[ PATH_MAX + XTM_GL_MAX_ARCH_NAME + 10 ]; 456 char file_name[ PATH_MAX + 1 ]; 457 char short_name[ XTM_GL_MAX_ARCH_NAME + 1 ]; 458 char *buffer_ref; 459 Arg args[ 3 ]; 460 Cardinal n; 461 Widget baseW; 462 Widget listW; 463 Widget mainW; 464 Widget tempW; 465 XmString *items; 466 XmString xstr; 467 468 469 /* Code. */ 470 471 baseW = xitGetParentWidget( widget, "ArchiveFd" ); 472 mainW = XtNameToWidget( baseW, "ArchiveFdFo" ); 473 474 /* Fetch the short name. */ 475 tempW = XtNameToWidget( mainW, "NameRc.NameTx" ); 476 477 buffer_ref = xitStringGetText( tempW ); 478 479 item_count = sscanf( buffer_ref, "%s", short_name ); 480 SysFree( buffer_ref ); 481 482 if( item_count == 0 ) 483 return; 484 485 486 /* Fetch the file name. */ 487 tempW = XtNameToWidget( mainW, "FileRc.FileTx" ); 488 489 buffer_ref = xitStringGetText( tempW ); 490 491 item_count = sscanf( buffer_ref, "%s", file_name ); 492 SysFree( buffer_ref ); 493 494 if( item_count == 0 ) 495 return; 496 497 498 /* Add the short name/directory to the scrolled list. */ 499 sprintf( buffer, "%-15.15s %s", short_name, file_name ); 500 501 xstr = XmStringCreate( buffer, CS ); 502 503 /* Check if we have an archive with this name. */ 504 listW = XtNameToWidget( mainW, "ArchLiSW.ArchLi" ); 505 506 n = 0; 507 XtSetArg( args[ n ], XmNitemCount, &item_count ); n++; 508 XtSetArg( args[ n ], XmNitems, &items ); n++; 509 XtGetValues( listW, args, n ); 510 511 found_position = 0; 512 513 for( index = 0; index < item_count; index++ ) { 514 buffer_ref = xitStringGetString( *(items + index), CS ); 515 516 sscanf( buffer_ref, "%s", buffer ); 517 518 SysFree( buffer_ref ); 519 520 if( strcmp( short_name, buffer ) == 0 ) { 521 found_position = index + 1; 522 break; 523 } 524 } /* loop */ 525 526 527 /* Does the entry already exist? */ 528 if( found_position > 0 ) 529 XmListDeletePos( listW, found_position ); 530 531 /* Add the new entry. */ 532 XmListAddItem( listW, xstr, 0 ); 533 XmListSetBottomPos( listW, 0 ); 534 XmListDeselectAllItems( listW ); 535 536 XmStringFree( xstr ); 537 538 /* Remove name and filename. */ 539 tempW = XtNameToWidget( mainW, "NameRc.NameTx" ); 540 XmTextSetString( tempW, "" ); 541 542 tempW = XtNameToWidget( mainW, "FileRc.FileTx" ); 543 XmTextSetString( tempW, "" ); 544 545 /* No items are selected in the list. */ 546 tempW = XtNameToWidget( mainW, "ArchLiSW.ArchLi" ); 547 XmListDeselectAllItems( tempW ); 548 549 tempW = XtNameToWidget( mainW, "ActionRc" ); 550 setAction( tempW, True, False ); 551 552 553 return; 554 555 } /* addCB */ 556 557 558 /*----------------------------------------------------------------------*/ 559 560 static void archiveListCB(Widget widget,XTM_CU_BASE_DATA_REF appl_data_ref,XmListCallbackStruct * call_data)561 archiveListCB( Widget widget, 562 XTM_CU_BASE_DATA_REF appl_data_ref, 563 XmListCallbackStruct *call_data ) 564 { 565 566 /* Variables. */ 567 char file_name[ PATH_MAX + 1 ]; 568 char short_name[ XTM_GL_MAX_ARCH_NAME + 1 ]; 569 char *buffer_ref; 570 Widget baseW; 571 Widget mainW; 572 Widget tempW; 573 574 575 /* Code. */ 576 577 baseW = xitGetParentWidget( widget, "ArchiveFd" ); 578 mainW = XtNameToWidget( baseW, "ArchiveFdFo" ); 579 580 /* Fetch the selected name/file line. */ 581 buffer_ref = xitStringGetString( call_data -> item, CS ); 582 583 sscanf( buffer_ref, "%[^ ] %[^ ]", short_name, file_name ); 584 585 /* Set short name and directory. */ 586 tempW = XtNameToWidget( mainW, "NameRc.NameTx" ); 587 XmTextSetString( tempW, short_name ); 588 589 tempW = XtNameToWidget( mainW, "FileRc.FileTx" ); 590 XmTextSetString( tempW, file_name ); 591 592 SysFree( buffer_ref ); 593 594 595 tempW = XtNameToWidget( mainW, "ActionRc" ); 596 setAction( tempW, True, True ); 597 598 599 return; 600 601 } /* archiveListCB */ 602 603 604 /*----------------------------------------------------------------------*/ 605 606 static void clearArchCB(void * element)607 clearArchCB( void *element ) 608 { 609 610 /* Variables. */ 611 XTM_AR_ARCHIVE_FILE *entry_ref; 612 613 614 /* Code. */ 615 616 entry_ref = (XTM_AR_ARCHIVE_FILE *) element; 617 618 if( entry_ref -> file_name != NULL ) 619 SysFree( entry_ref -> file_name ); 620 621 622 return; 623 624 } /* clearArchCB */ 625 626 627 /*----------------------------------------------------------------------*/ 628 629 static void deleteCB(Widget widget,XTM_CU_BASE_DATA_REF appl_data_ref,XtPointer call_data)630 deleteCB( Widget widget, 631 XTM_CU_BASE_DATA_REF appl_data_ref, 632 XtPointer call_data ) 633 { 634 635 /* Variables. */ 636 int selected_item_count; 637 Arg args[ 3 ]; 638 Cardinal n; 639 Widget baseW; 640 Widget mainW; 641 Widget tempW; 642 Widget listW; 643 XmString *selected_items; 644 645 646 /* Code. */ 647 648 baseW = xitGetParentWidget( widget, "ArchiveFd" ); 649 mainW = XtNameToWidget( baseW, "ArchiveFdFo" ); 650 listW = XtNameToWidget( mainW, "ArchLiSW.ArchLi" ); 651 652 /* Fetch selected items from the list. */ 653 n = 0; 654 XtSetArg( args[ n ], XmNselectedItemCount, &selected_item_count ); n++; 655 XtSetArg( args[ n ], XmNselectedItems, &selected_items ); n++; 656 XtGetValues( listW, args, n ); 657 658 if( selected_item_count != 1 ) 659 return; 660 661 /* Delete the selected short name/directory. */ 662 XmListDeleteItem( listW, *selected_items ); 663 664 /* Remove name and filename. */ 665 tempW = XtNameToWidget( mainW, "NameRc.NameTx" ); 666 XmTextSetString( tempW, "" ); 667 668 tempW = XtNameToWidget( mainW, "FileRc.FileTx" ); 669 XmTextSetString( tempW, "" ); 670 671 /* No items are selected in the list. */ 672 XmListDeselectAllItems( listW ); 673 674 tempW = XtNameToWidget( mainW, "ActionRc" ); 675 setAction( tempW, True, False ); 676 677 678 return; 679 680 } /* deleteCB */ 681 682 683 /*----------------------------------------------------------------------*/ 684 685 static void helpCB(Widget widget,XTM_CU_BASE_DATA_REF appl_data_ref,XtPointer call_data)686 helpCB( Widget widget, 687 XTM_CU_BASE_DATA_REF appl_data_ref, 688 XtPointer call_data ) 689 { 690 691 /* Code. */ 692 693 xtmHlDisplayHelp( appl_data_ref -> info_handle, 694 XTM_HL_WINDOW_INDEX, 695 cust_arch_window_id, "" ); 696 697 return; 698 699 } /* helpCB */ 700 701 702 /*----------------------------------------------------------------------*/ 703 704 static void okCB(Widget widget,XTM_CU_BASE_DATA_REF appl_data_ref,XtPointer call_data)705 okCB( Widget widget, 706 XTM_CU_BASE_DATA_REF appl_data_ref, 707 XtPointer call_data ) 708 { 709 710 /* Variables. */ 711 int index; 712 int item_count; 713 char file_name[ PATH_MAX + 1 ]; 714 char *buffer_ref; 715 Arg args[ 3 ]; 716 Cardinal n; 717 Widget baseW; 718 Widget mainW; 719 Widget listW; 720 XmString *items; 721 LST_STATUS lst_status; 722 XTM_AR_ARCHIVE_FILE archive_file; 723 XTM_GL_CUSTOM_DATA_REF custom_data; 724 725 726 /* Code. */ 727 728 custom_data = appl_data_ref -> custom_data; 729 730 baseW = xitGetParentWidget( widget, "ArchiveFd" ); 731 mainW = XtNameToWidget( baseW, "ArchiveFdFo" ); 732 733 734 /* Fetch the archive files. */ 735 listW = XtNameToWidget( mainW, "ArchLiSW.ArchLi" ); 736 737 n = 0; 738 XtSetArg( args[ n ], XmNitemCount, &item_count ); n++; 739 XtSetArg( args[ n ], XmNitems, &items ); n++; 740 XtGetValues( listW, args, n ); 741 742 /* Free old database location data and create a new list. */ 743 LstLinkClearDataAndList( custom_data -> archive_files, clearArchCB ); 744 745 custom_data -> archive_files = LstLinkNew( sizeof( XTM_AR_ARCHIVE_FILE ), 746 NULL ); 747 748 /* Fetch all archive files and assign them to the database list. */ 749 for( index = 0; index < item_count; index++ ) { 750 751 buffer_ref = xitStringGetString( *(items + index), CS ); 752 753 sscanf( buffer_ref, "%s %s", archive_file.short_name, file_name ); 754 755 archive_file.file_name = SysNewString( file_name ); 756 757 SysFree( buffer_ref ); 758 759 lst_status = LstLinkInsertLast( custom_data -> archive_files, 760 &archive_file ); 761 762 } /* loop */ 763 764 765 /* Remove the archive window. */ 766 XtDestroyWidget( baseW ); 767 768 return; 769 770 } /* okCB */ 771