home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / AddrBookFrame.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  17.1 KB  |  661 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /* 
  19.    AddrBookFrame.cpp -- address book window stuff.
  20.    Created: Chris Toshok <toshok@netscape.com>, 29-Aug-96.
  21.    Revised: Tao Cheng <tao@netscape.com>, 01-nov-96
  22.  */
  23.  
  24. #include "AddrBookFrame.h"
  25. #include "LdapSearchFrame.h"
  26.  
  27. #include "AB2PaneView.h"
  28. #include "AddrBookView.h"
  29.  
  30. #include "ComposeView.h"
  31. #include "ComposeFolderView.h"
  32. #include "Dashboard.h"
  33. #include <Xfe/Xfe.h>
  34.  
  35. #include "xpassert.h"
  36.  
  37. #include "prefs.h"
  38. #include "prefapi.h"
  39.  
  40. #include <Xm/Form.h>
  41. #include <Xm/Label.h>
  42. #include <Xm/PushB.h>
  43. #include <Xm/TextF.h>
  44. #include <Xm/DialogS.h>
  45. #include <Xm/FileSB.h>
  46.  
  47. #include "DtWidgets/ComboBox.h"
  48.  
  49. extern "C" {
  50. #include "xfe.h"
  51.  
  52. XP_List* FE_GetDirServers();
  53. };
  54.  
  55. MenuSpec XFE_AddrBookFrame::file_menu_spec[] = {
  56.   { "newSubmenu",        CASCADEBUTTON,
  57.     (MenuSpec*)&XFE_Frame::new_menu_spec },
  58.   { xfeCmdAddToAddressBook,    PUSHBUTTON },
  59.   { xfeCmdABNewList,        PUSHBUTTON },
  60.   { xfeCmdImport,        PUSHBUTTON },
  61.   MENU_SEPARATOR,
  62.   { xfeCmdSaveAs,        PUSHBUTTON },
  63.   { xfeCmdABCall,        PUSHBUTTON },
  64.   MENU_SEPARATOR,
  65.   { xfeCmdClose,        PUSHBUTTON },
  66.   { xfeCmdExit,        PUSHBUTTON },
  67.   { NULL }
  68. };
  69.  
  70. MenuSpec XFE_AddrBookFrame::edit_menu_spec[] = {
  71.   { xfeCmdUndo,            PUSHBUTTON },
  72.   { xfeCmdRedo,            PUSHBUTTON },
  73.   MENU_SEPARATOR,
  74. #if 0
  75.   /* do not take out yet */
  76.   { xfeCmdCut,            PUSHBUTTON },
  77.   { xfeCmdCopy,            PUSHBUTTON },
  78.   { xfeCmdPaste,        PUSHBUTTON },
  79. #endif
  80.   { xfeCmdABDeleteEntry,PUSHBUTTON },
  81.   { xfeCmdSelectAll,    PUSHBUTTON },
  82.   MENU_SEPARATOR,
  83.   { xfeCmdSearchAddress,        PUSHBUTTON },
  84.   MENU_SEPARATOR,
  85.   { xfeCmdDisplayHTMLDomainsDialog,    PUSHBUTTON },
  86.   { xfeCmdViewProperties,    PUSHBUTTON },
  87.   { xfeCmdEditPreferences,    PUSHBUTTON },
  88.   { NULL }
  89. };
  90.  
  91. MenuSpec XFE_AddrBookFrame::view_menu_spec[] = {
  92.     { xfeCmdToggleNavigationToolbar,    PUSHBUTTON },
  93.     MENU_SEPARATOR,
  94.     { xfeCmdABByType,    
  95.       TOGGLEBUTTON, NULL, "AddrBookViewSortTypeGroup" },
  96.     { xfeCmdABByName,    
  97.       TOGGLEBUTTON, NULL, "AddrBookViewSortTypeGroup" },
  98.     { xfeCmdABByEmailAddress,    
  99.       TOGGLEBUTTON, NULL, "AddrBookViewSortTypeGroup" },
  100.     { xfeCmdABByNickName,    
  101.       TOGGLEBUTTON, NULL, "AddrBookViewSortTypeGroup" },
  102.     { xfeCmdABByCompany,    
  103.       TOGGLEBUTTON, NULL, "AddrBookViewSortTypeGroup" },
  104.     { xfeCmdABByLocality,    
  105.       TOGGLEBUTTON, NULL, "AddrBookViewSortTypeGroup" },
  106.     MENU_SEPARATOR,
  107.     { xfeCmdSortAscending,    
  108.       TOGGLEBUTTON, NULL, "AddrBookViewSortOrderGroup" },
  109.     { xfeCmdSortDescending,    
  110.       TOGGLEBUTTON, NULL, "AddrBookViewSortOrderGroup" },
  111.     MENU_SEPARATOR,
  112.     { xfeCmdABvCard,    PUSHBUTTON },
  113.     { NULL }
  114. };
  115.  
  116. MenuSpec XFE_AddrBookFrame::menu_bar_spec[] = {
  117.   { xfeMenuFile,     CASCADEBUTTON, 
  118.     (MenuSpec*)&XFE_AddrBookFrame::file_menu_spec },
  119.   { xfeMenuEdit,     CASCADEBUTTON, 
  120.     (MenuSpec*)&XFE_AddrBookFrame::edit_menu_spec },
  121.   { xfeMenuView,     CASCADEBUTTON, 
  122.     (MenuSpec*)&XFE_AddrBookFrame::view_menu_spec },
  123.   { xfeMenuWindow,     CASCADEBUTTON, 
  124.     (MenuSpec*)&XFE_Frame::window_menu_spec },
  125.   { xfeMenuHelp,     CASCADEBUTTON,
  126.     (MenuSpec*)&XFE_Frame::help_menu_spec },
  127.   { NULL }
  128. };
  129.  
  130. ToolbarSpec XFE_AddrBookFrame::toolbar_spec[] = {
  131.   { xfeCmdAddToAddressBook,    PUSHBUTTON, &MNAB_NewPerson_group},
  132.   { xfeCmdABNewList,            PUSHBUTTON, &MNAB_NewList_group},
  133.   { xfeCmdABEditEntry,        PUSHBUTTON, &MNAB_Properties_group},
  134.  
  135.   {  // XX mail only
  136.     xfeCmdComposeMessage,
  137.     CASCADEBUTTON,
  138.     &MNTB_Compose_group, NULL, NULL, NULL, // Icons
  139.     compose_message_submenu_spec, // Submenu spec
  140.     NULL, NULL, // Generate proc/arg
  141.     XFE_TOOLBAR_DELAY_LONG // Popup delay
  142.   },
  143.  
  144.   { xfeCmdSearchAddress,            PUSHBUTTON, &MNC_Directory_group},
  145.   { xfeCmdABCall,            PUSHBUTTON, &MNAB_Call_group},
  146.   { xfeCmdABDeleteEntry,    PUSHBUTTON, &MNTB_Trash_group},
  147.   { xfeCmdStopLoading,        PUSHBUTTON, &TB_Stop_group },
  148.   { NULL }
  149. };
  150.  
  151. MenuSpec XFE_AddrBookFrame::frame_popup_spec[] = {
  152.   { xfeCmdAddToAddressBook,    PUSHBUTTON },
  153.   { xfeCmdABNewList,        PUSHBUTTON },
  154.   { NULL }
  155. };
  156.  
  157.  
  158. extern "C" {
  159.     Widget fe_CreateFileSelectionBox(Widget, char*, Arg*, Cardinal);
  160.     const char *FE_UsersFullName (void);
  161. };
  162.  
  163. #include "xpgetstr.h"
  164.  
  165. extern int XFE_AB_FRAME_TITLE;
  166. /* Hack:
  167.  * pixmaps for the address book. 
  168.  */
  169. XFE_Frame* XFE_AddrBookFrame::m_theFrame = 0;
  170. //
  171. XFE_AddrBookFrame::XFE_AddrBookFrame(Widget toplevel, 
  172.                                      XFE_Frame *parent_frame,
  173.                                      Chrome *chromespec) 
  174.   : XFE_Frame("AddressBook",
  175.               toplevel, 
  176.               parent_frame,
  177.               FRAME_ADDRESSBOOK,
  178.               chromespec,
  179.               False /* HTML */,
  180.               True  /* menuBar */, 
  181.               True /* toolBar */, 
  182.               True  /* dashBoard */,
  183.               True /* destroyOnClose */),
  184.     m_popup(0)
  185. {
  186.   m_abView = 0;
  187.   setToolbar(toolbar_spec);
  188.   /* create the addressbook view; 
  189.    * import from XFE_BookmarkFrame::XFE_BookmarkFrame
  190.    */
  191.   XFE_AB2PaneView *view = new XFE_AB2PaneView(this, 
  192.                                               getViewParent(), 
  193.                                               NULL,
  194.                                               m_context,
  195.                                               AB_BOOK);
  196.   m_abView = (XFE_AddrBookView *) view->getEntriesListView();
  197.  
  198.   /* Attachment
  199.    */
  200.   XtVaSetValues(view->getBaseWidget(),
  201.         XmNleftAttachment, XmATTACH_FORM,
  202.         XmNtopAttachment, XmATTACH_FORM,
  203.         XmNrightAttachment, XmATTACH_FORM,
  204.         XmNbottomAttachment, XmATTACH_FORM,
  205.         NULL);
  206.  
  207.   setView(view);
  208.   setMenubar(menu_bar_spec);
  209.  
  210.   char title[kMaxFullNameLength+64];
  211.   PR_snprintf(title, sizeof(title),
  212.               XP_GetString(XFE_AB_FRAME_TITLE),
  213.               FE_UsersFullName());
  214.   setTitle(title);
  215.  
  216.   /* show 
  217.    */
  218.   view->show();
  219.  
  220.   m_dashboard->setShowStatusBar(True);
  221.   m_dashboard->setShowProgressBar(True);
  222.   //
  223.   m_dashboard->setShowSecurityIcon(True);
  224.  
  225.   // Configure the toolbox for the first time
  226.   configureToolbox();
  227. }
  228.  
  229. XFE_AddrBookFrame::~XFE_AddrBookFrame()
  230. {
  231.     m_theFrame = 0;
  232. }
  233.  
  234. XP_Bool XFE_AddrBookFrame::handlesCommand(CommandType cmd, 
  235.                                           void */* calldata */,
  236.                                           XFE_CommandInfo* /* info */)
  237. {
  238.   if (cmd == xfeCmdShowPopup
  239.       || cmd == xfeCmdImport
  240.       || cmd == xfeCmdSaveAs
  241.       || cmd == xfeCmdStopLoading
  242.       || cmd == xfeCmdUndo
  243.       || cmd == xfeCmdRedo
  244.       || cmd == xfeCmdABDeleteEntry
  245.       || cmd == xfeCmdFindInObject
  246.       || cmd == xfeCmdFindAgain
  247.       || cmd == xfeCmdSearchAddress
  248.       || cmd == xfeCmdEditPreferences
  249.       || cmd == xfeCmdABByType
  250.       || cmd == xfeCmdABByName
  251.       || cmd == xfeCmdABByEmailAddress
  252.       || cmd == xfeCmdABByCompany
  253.       || cmd == xfeCmdABByLocality
  254.       || cmd == xfeCmdABByNickName
  255.       || cmd == xfeCmdSortAscending
  256.       || cmd == xfeCmdSortDescending
  257.       || cmd == xfeCmdAddToAddressBook
  258.       || cmd == xfeCmdABNewList
  259.       || cmd == xfeCmdViewProperties
  260.       || cmd == xfeCmdDisplayHTMLDomainsDialog
  261.       || cmd == xfeCmdABEditEntry
  262.       || cmd == xfeCmdABDeleteEntry
  263.       || cmd == xfeCmdABCall
  264.       || cmd == xfeCmdABvCard)
  265.       return TRUE;
  266.   else
  267.       /* Default
  268.        */
  269.       return XFE_Frame::handlesCommand(cmd);
  270. }
  271.  
  272. char *XFE_AddrBookFrame::commandToString(CommandType cmd,
  273.                            void *calldata, XFE_CommandInfo* info)
  274. {
  275.     XFE_Command* handler = getCommand(cmd);
  276.  
  277.     if (handler != NULL)
  278.         return handler->getLabel(this, info);
  279.  
  280.     if (cmd == xfeCmdToggleNavigationToolbar) {
  281.         char *res = NULL;
  282.         
  283.         if (m_toolbar->isShown())
  284.             res = "hideNavToolbarCmdString";
  285.         else
  286.             res = "showNavToolbarCmdString";
  287.         return stringFromResource(res);
  288.     }
  289.     else
  290.         return XFE_Frame::commandToString(cmd, calldata, info);
  291. }
  292.  
  293. XP_Bool
  294. XFE_AddrBookFrame::isCommandEnabled(CommandType cmd, void *, XFE_CommandInfo*)
  295. {
  296.   /* first we handle the commands we know about.. 
  297.    * xfeCmdClose xfeCmdEditPreferences 
  298.    */
  299.   if (cmd == xfeCmdOpenInbox
  300.       || cmd == xfeCmdOpenNewsgroups
  301.       || cmd == xfeCmdOpenFolders
  302.  
  303.       || cmd == xfeCmdSearchAddress
  304.       || cmd == xfeCmdEditPreferences
  305.  
  306.       || cmd == xfeCmdOpenBookmarks
  307.  
  308. #ifdef JAVA
  309.       || cmd == xfeCmdJavaConsole 
  310. #endif /* JAVA */
  311.  
  312.       || cmd == xfeCmdSelectAll
  313.       || cmd == xfeCmdABvCard
  314.  
  315.       || cmd == xfeCmdDisplayHTMLDomainsDialog) {
  316.       return TRUE;
  317.   }/* if */
  318.   else if (cmd == xfeCmdOpenAddressBook) {
  319.       return FALSE;
  320.   }/* else if */
  321.   else if (cmd == xfeCmdStopLoading) {
  322.       return m_abView?m_abView->isSearching():False;
  323.   }/* else if */
  324.   else {
  325.     return XFE_Frame::isCommandEnabled(cmd);
  326.   }/* else */
  327. }
  328.  
  329. char *XFE_AddrBookFrame::getDocString(CommandType cmd)
  330. {
  331.     if ((cmd == xfeCmdComposeMessage ||
  332.         (cmd == xfeCmdComposeMessageHTML) ||
  333.         (cmd == xfeCmdComposeMessagePlain) ||
  334.         cmd == xfeCmdABCall) && m_abView)
  335.         return m_abView->getDocString(cmd);
  336.     return XFE_Frame::getDocString(cmd);
  337. }
  338.  
  339. char *XFE_AddrBookFrame::getTipString(CommandType /* cmd */)
  340. {
  341.     return NULL;
  342. }
  343.  
  344. void XFE_AddrBookFrame::doCommand(CommandType cmd, 
  345.                                   void *calldata, XFE_CommandInfo* info)
  346. {
  347.   /* first we handle the commands we know about. 
  348.    */
  349.  
  350.   /* file_menu_spec xfeCmdClose
  351.    */
  352.   if (cmd == xfeCmdComposeMessage) 
  353.       composeMessage();
  354.   else if (cmd == xfeCmdStopLoading) 
  355.       m_abView->stopSearch();
  356.   else if (cmd == xfeCmdComposeMessageHTML) 
  357.   {
  358.      CONTEXT_DATA(m_context)->stealth_cmd = 
  359.             (fe_globalPrefs.send_html_msg == False);
  360.      composeMessage();
  361.   }
  362.   else if ( cmd == xfeCmdComposeMessagePlain) 
  363.   {
  364.      CONTEXT_DATA(m_context)->stealth_cmd = 
  365.             (fe_globalPrefs.send_html_msg == True);
  366.      composeMessage();
  367.   }
  368.   else if (cmd == xfeCmdImport)
  369.     import();
  370.   else if (cmd == xfeCmdSaveAs)
  371.     saveAs();
  372.   /* edit_menu_spec
  373.    */
  374.   else if (cmd == xfeCmdUndo)
  375.     undo();
  376.   else if (cmd == xfeCmdRedo)
  377.     redo();
  378.   else if (cmd == xfeCmdABDeleteEntry)
  379.     abDelete();
  380.   else if (cmd == xfeCmdFindInObject)
  381.     printf("\n %s", xfeCmdComposeMessage);
  382.   else if (cmd == xfeCmdFindAgain)
  383.     printf("\n %s", xfeCmdComposeMessage);
  384.   else if (cmd == xfeCmdSearchAddress) {
  385.       fe_showLdapSearch(XfeAncestorFindApplicationShell(getBaseWidget()), this, (Chrome*)NULL);
  386.   }/* else if */
  387.   else if (cmd == xfeCmdEditPreferences)
  388.     fe_showMailNewsPreferences(this, (MWContext*)m_view->getContext());
  389.  
  390.   /* view_menu_spec
  391.    */
  392. #if defined(USE_ABCOM)
  393.   else if (cmd == xfeCmdABByType) {
  394.     m_abView->setSortType(AB_attribEntryType);
  395.   }
  396.   else if (cmd == xfeCmdABByName) {
  397.     m_abView->setSortType(AB_attribFullName);
  398.   }
  399.   else if (cmd == xfeCmdABByEmailAddress) {
  400.     m_abView->setSortType(AB_attribEmailAddress);
  401.   }
  402.   else if (cmd == xfeCmdABByCompany) {
  403.     m_abView->setSortType(AB_attribCompanyName);
  404.   }
  405.   else if (cmd == xfeCmdABByLocality) {
  406.     m_abView->setSortType(AB_attribLocality);
  407.   }
  408.   else if (cmd == xfeCmdABByNickName) {
  409.     m_abView->setSortType(AB_attribNickName);
  410.   }
  411. #else
  412.   else if (cmd == xfeCmdABByType) {
  413.     m_abView->setSortType(AB_SortByTypeCmd);
  414.   }
  415.   else if (cmd == xfeCmdABByName) {
  416.     m_abView->setSortType(AB_SortByFullNameCmd);
  417.   }
  418.   else if (cmd == xfeCmdABByEmailAddress) {
  419.     m_abView->setSortType(AB_SortByEmailAddress);
  420.   }
  421.   else if (cmd == xfeCmdABByCompany) {
  422.     m_abView->setSortType(AB_SortByCompanyName);
  423.   }
  424.   else if (cmd == xfeCmdABByLocality) {
  425.     m_abView->setSortType(AB_SortByLocality);
  426.   }
  427.   else if (cmd == xfeCmdABByNickName) {
  428.     m_abView->setSortType(AB_SortByNickname);
  429.   }
  430. #endif /* USE_ABCOM */
  431.   else if (cmd == xfeCmdSortAscending) {
  432.     m_abView->setAscending(True);
  433.   }
  434.   else if (cmd == xfeCmdSortDescending) {
  435.     m_abView->setAscending(False);
  436.   }
  437.   /* item_menu_spec
  438.    */
  439.   else if (cmd == xfeCmdAddToAddressBook)
  440.     /* Add new user
  441.      */
  442.     addToAddressBook();
  443.   else if (cmd == xfeCmdABNewList)
  444.     /* Add new list
  445.      */
  446.     newList();
  447.   else if (cmd == xfeCmdViewProperties)
  448.     /* Edit property
  449.      */
  450.     viewProperties();
  451.  
  452.   else if (cmd == xfeCmdDisplayHTMLDomainsDialog)
  453.     
  454.       MSG_DisplayHTMLDomainsDialog((MWContext*)m_view->getContext());
  455.   /* ToolBar
  456.    */
  457.   else if (cmd == xfeCmdABEditEntry)
  458.     /* Edit property
  459.      */
  460.     viewProperties();
  461.   else if (cmd == xfeCmdABDeleteEntry)
  462.     abDelete();
  463.   else if (cmd == xfeCmdABCall)
  464.       abCall();
  465.   else if (cmd == xfeCmdABvCard)
  466.       abVCard();
  467.   else    if (cmd == xfeCmdShowPopup) {
  468.         // Finish up the popup
  469.         XEvent *event = info->event;
  470.  
  471.         if (m_popup)
  472.             delete m_popup;
  473.         
  474.         m_popup = new XFE_PopupMenu("popup",(XFE_Frame *) this,
  475.                                     XfeAncestorFindApplicationShell(getBaseWidget()));
  476.         m_popup->addMenuSpec(frame_popup_spec);
  477.         m_popup->position (event);
  478.         m_popup->show();
  479.   }/* else if */
  480.   else
  481.     /* Default
  482.      */
  483.     XFE_Frame::doCommand(cmd, calldata, info);
  484. }/* XFE_AddrBookFrame::doCommand() */
  485.  
  486.  
  487. void XFE_AddrBookFrame::openBrowser() {
  488.  
  489. }
  490.  
  491. void XFE_AddrBookFrame::composeMessage() {
  492.   MSG_Pane *pane = NULL;
  493.   pane = MSG_Mail((MWContext*)m_abView->getContext());
  494.  
  495.   ABAddrMsgCBProcStruc *pairs = ((XFE_AddrBookView*)m_abView)->getSelections();
  496.  
  497.   if (pairs && pairs->m_count) {
  498.       XFE_ComposeView *composeView = (XFE_ComposeView *)MSG_GetFEData(pane);
  499.  
  500.       if (composeView) {
  501.           XFE_ComposeFolderView *composeFolderView = 
  502.               (XFE_ComposeFolderView *)composeView->getComposeFolderView();
  503.           
  504.           if (composeFolderView)
  505.               composeFolderView->getAddrFolderView()->addrMsgCB(pairs);
  506.       }/* if */
  507.   }/* if */
  508. }
  509.  
  510. void XFE_AddrBookFrame::abAddToMessage() 
  511. {
  512. }
  513.  
  514. void XFE_AddrBookFrame::import() 
  515. {
  516.  
  517.   AB_ImportFromFile(((XFE_AddrBookView *)m_abView)->getABPane(),
  518.                     (MWContext *)m_abView->getContext());
  519.  
  520. }/* XFE_AddrBookFrame::import() */
  521.  
  522. void XFE_AddrBookFrame::saveAs()
  523. {
  524.  
  525.     AB_ExportToFile(((XFE_AddrBookView *)m_view)->getABPane(),
  526.                     (MWContext *)m_abView->getContext());
  527.  
  528. }
  529.  
  530. XP_Bool XFE_AddrBookFrame::isOkToClose()
  531. {
  532.   XFE_ABListSearchView *searchView = (XFE_ABListSearchView *) m_abView;
  533.   searchView->unRegisterInterested();
  534.   return TRUE;
  535. }/* XFE_AddrBookFrame::isOkToClose() */
  536.  
  537. void XFE_AddrBookFrame::close() {
  538.   delete_response();
  539. }
  540.  
  541. void XFE_AddrBookFrame::undo() {
  542.   m_abView->undo();
  543. }
  544.  
  545. void XFE_AddrBookFrame::redo() {
  546.   m_abView->redo();
  547. }
  548.  
  549. void XFE_AddrBookFrame::abDelete() {
  550.   m_abView->delUser();
  551. }
  552.  
  553. void XFE_AddrBookFrame::addToAddressBook() {
  554.   /* shall this be new user ??
  555.    */
  556.   m_abView->newUser();
  557. }
  558.  
  559. void XFE_AddrBookFrame::abVCard() {
  560.   /* shall this be new user ??
  561.    */
  562.   m_abView->abVCard();
  563. }
  564.  
  565. void XFE_AddrBookFrame::newList() {
  566.   /* popup new lsit
  567.    */
  568.   m_abView->newList();
  569. }
  570.  
  571. void XFE_AddrBookFrame::viewProperties() { 
  572.   /* edit property
  573.    */
  574.   m_abView->editProperty();
  575. }
  576.  
  577. void XFE_AddrBookFrame::abCall() { 
  578.   m_abView->abCall();
  579. }
  580.  
  581. /* C API
  582.  */
  583. extern "C"  MWContext*
  584. fe_showAddrBook(Widget toplevel, XFE_Frame *parent_frame, Chrome *chromespec)
  585. {
  586.  
  587.     if (!XFE_AddrBookFrame::m_theFrame)
  588.         XFE_AddrBookFrame::m_theFrame = 
  589.             new XFE_AddrBookFrame(toplevel, parent_frame, chromespec);
  590.  
  591.     XFE_AddrBookFrame::m_theFrame->show();
  592.     
  593.     return XFE_AddrBookFrame::m_theFrame->getContext();
  594. }
  595.  
  596. //////////////////////////////////////////////////////////////////////////
  597. //
  598. // Toolbox methods
  599. //
  600. //////////////////////////////////////////////////////////////////////////
  601. void
  602. XFE_AddrBookFrame::toolboxItemClose(XFE_ToolboxItem * item)
  603. {
  604.     XP_ASSERT( item != NULL );
  605.  
  606.     // Address_Book_Toolbar
  607.     if (item == m_toolbar)
  608.     {
  609.         fe_globalPrefs.address_book_address_book_toolbar_open = False;
  610.     }
  611. }
  612. //////////////////////////////////////////////////////////////////////////
  613. void
  614. XFE_AddrBookFrame::toolboxItemOpen(XFE_ToolboxItem * item)
  615. {
  616.     XP_ASSERT( item != NULL );
  617.  
  618.     // Address_Book_Toolbar
  619.     if (item == m_toolbar)
  620.     {
  621.         fe_globalPrefs.address_book_address_book_toolbar_open = True;
  622.     }
  623. }
  624. //////////////////////////////////////////////////////////////////////////
  625. void
  626. XFE_AddrBookFrame::toolboxItemChangeShowing(XFE_ToolboxItem * item)
  627. {
  628.     XP_ASSERT( item != NULL );
  629.  
  630.     // Address_Book_Toolbar
  631.     if (item == m_toolbar)
  632.     {
  633.         fe_globalPrefs.address_book_address_book_toolbar_showing = item->isShown();
  634.     }
  635. }
  636. //////////////////////////////////////////////////////////////////////////
  637. void
  638. XFE_AddrBookFrame::configureToolbox()
  639. {
  640.     // If a the frame was constructed with a chromespec, then we ignore
  641.     // all the preference magic.
  642.     if (m_chromespec_provided)
  643.     {
  644.         return;
  645.     }
  646.  
  647.     // Make sure the toolbox is alive
  648.     if (!m_toolbox || (m_toolbox && !m_toolbox->isAlive()))
  649.     {
  650.         return;
  651.     }
  652.  
  653.     // Address_Book_Toolbar
  654.     if (m_toolbar)
  655.     {
  656.         m_toolbar->setShowing(fe_globalPrefs.address_book_address_book_toolbar_showing);
  657.         m_toolbar->setOpen(fe_globalPrefs.address_book_address_book_toolbar_open);
  658.     }
  659. }
  660. //////////////////////////////////////////////////////////////////////////
  661.