⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwinc.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* *  $Id: MainWinC.C,v 1.7 2001/07/22 16:18:06 evgeny Exp $ *   *  Copyright (c) 1994 HAL Computer Systems International, Ltd. *  *          HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. *                  1315 Dell Avenue *                  Campbell, CA  95008 * * Author: Greg Hilton * Contributors: Tom Lang, Frank Bieser, and others * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * http://www.gnu.org/copyleft/gpl.html * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */#include <config.h>#include "MainWinC.h"#include "MainWinP.h"#include "IshAppC.h"#include "AppPrefC.h"#include "FolderC.h"#include "AddressC.h"#include "MsgC.h"#include "MsgItemC.h"#include "SumPrefC.h"#include "SortMgrC.h"#include "SortPrefC.h"#include "FolderPrefC.h"#include "UndelWinC.h"#include "ButtonMgrC.h"#include "MainButtPrefC.h"#include "AutoFilePrefC.h"#include "QuickMenu.h"#include "MsgFindWinC.h"#include "ReadWinC.h"#include "MsgListC.h"#include <hgl/VItemC.h>#include <hgl/VBoxC.h>#include <hgl/TBoxC.h>#include <hgl/rsrc.h>#include <hgl/SysErr.h>#include <hgl/FieldViewC.h>#include <hgl/WXmString.h>#include <unistd.h>#include <errno.h>/*--------------------------------------------------------------- *  Main window constructor */MainWinC::MainWinC(Widget parent) : HalMainWinC("mainShell", parent){   priv		   = new MainWinP(this);   curFolder       = NULL;   curMsgList	   = new VItemListC;   readingSelected = False;   popupFolder	   = NULL;   popupMsg	   = NULL;   popupOnSelected = False;   priv->BuildMenus();   priv->BuildWidgets();   priv->ReadResources();//// Create the message sort manager//   sortMgr = new SortMgrC(ishApp->sortPrefs->sortKeys);//// Create the custom button manager//   buttMgr = new ButtonMgrC(this, menuBar, priv->msgTBox->ButtonBox(),			    ishApp->mainButtPrefs->buttonStr, priv->msgTBox);   AddMapCallback((CallbackFn *)MainWinP::DoMap, priv);} // End constructor/*--------------------------------------------------------------- *  Main window destructor */MainWinC::~MainWinC(){   delete priv;   delete curMsgList;   delete sortMgr;   delete buttMgr;} // End destructor/*--------------------------------------------------------------- *  Method to add a folder icon to the display */voidMainWinC::ShowFolder(FolderC *folder){   if ( folder->icon ) return;#if 0//// We need to scan the folder if we want the correct status icon//   if ( ishApp->folderPrefs->showStatus && !folder->scanned )      folder->Scan();#endif   folder->CreateIcon();   folder->icon->AddOpenCallback((CallbackFn *)MainWinP::OpenFolder,     priv);   folder->icon->AddMenuCallback((CallbackFn *)MainWinP::PostFolderMenu, priv);   folder->icon->SetMenu(priv->folderPU);   if ( !folder->isInBox )      ishApp->folderPrefs->AddOpenFolder(folder);   priv->folderVBox->AddItem(*folder->icon);} // End ShowFolder/*--------------------------------------------------------------- *  Method to add our callbacks to the message icon */voidMainWinC::RegisterMsgIcon(VItemC *icon){   icon->AddOpenCallback((CallbackFn *)MainWinP::OpenMessage, priv);   icon->AddMenuCallback((CallbackFn *)MainWinP::PostMsgMenu, priv);   icon->SetMenu(priv->msgPU);}/*------------------------------------------------------------------------ * Method to update summary field characteristics */voidMainWinC::UpdateFields(){   BusyCursor(True);//// Sort the field columns by position//   ishApp->sumPrefs->UpdateFields(priv->fieldView);//// Loop through all message items and reset the fields//   if ( ishApp->systemFolder ) ishApp->systemFolder->UpdateFields();   u_int	fcount = ishApp->folderPrefs->OpenFolders().size();   for (int f=0; f<fcount; f++) {      FolderC	*folder = ishApp->folderPrefs->OpenFolders()[f];      folder->UpdateFields();   }   priv->msgVBox->Refresh();   BusyCursor(False);} // End UpdateFields/*--------------------------------------------------------------- *  Method to update the title string */voidMainWinC::UpdateTitle(){   if ( ishApp->exiting || !curFolder ) return;//// Get the base string for the title//   StringC	label;   if ( curFolder->isInBox ) label = priv->systemTitleStr;   else			     label = priv->folderTitleStr;   if ( !curFolder->isInBox ) {      StringC	name = curFolder->name;      ishApp->AbbreviateFolderName(name);      if ( name.size() > 32 ) name += "\n";      label.Replace("$NAME", name);   }//// Add the total message count//   label += " (" + priv->msgCountStr;   int	count = (int)curFolder->MsgItemList().size() +		(int)curFolder->DelItemList().size();   StringC	countStr;   countStr += count;   label.Replace("$COUNT", countStr);//// Add the new message count//   int	newCount = curFolder->NewMsgCount();   if ( newCount > 0 ) {      label += ", " + priv->newMsgCountStr;      countStr.Clear();      countStr += newCount;      label.Replace("$COUNT", countStr);   }//// Add the unread message count//   count = curFolder->UnreadMsgCount();   if ( count > 0 ) {      label += ", " + priv->unrMsgCountStr;      countStr.Clear();      countStr += count;      label.Replace("$COUNT", countStr);   }//// Add the saved message count//   count = curFolder->SavedMsgCount();   if ( count > 0 ) {      label += ", " + priv->savMsgCountStr;      countStr.Clear();      countStr += count;      label.Replace("$COUNT", countStr);   }//// Add the deleted message count//   count = curFolder->DeletedMsgCount();   if ( count > 0 ) {      label += ", " + priv->delMsgCountStr;      countStr.Clear();      countStr += count;      label.Replace("$COUNT", countStr);   }   label += ")";   priv->msgTBox->Title(label);//// Update in-box icon if there's no more new mail//   if ( curFolder->isInBox && mapped )      curFolder->UpdateIcon();//// Update the application icon's title so summary info is available even// if the program is iconified.// (commented-out line updates the title at the top of the window, too,//  though this seems a bit redundant in addition to the status line in//  the main window.)//   label = "Ishmail: " + label;   char *titleString = label;   //XtVaSetValues(topLevel, XmNtitle, titleString, XmNiconName, titleString, NULL);   XtVaSetValues(topLevel, XmNiconName, titleString, NULL);//// Update application icon.  We have to do it here because some window//    managers show the icon even if the window is not iconified.//   PixmapC *pm;   if      ( ishApp->systemFolder->HasNewMessages() )      pm =  priv->NewMailPixmap();   else if ( ishApp->systemFolder->HasUnreadMessages() )      pm = priv->unreadMailPM;   else if ( ishApp->systemFolder->MsgItemList().size() > 0 )      pm = priv->readMailPM;   else      pm = priv->noMailPM;   XtVaSetValues(topLevel, XmNiconPixmap, pm->reg,                           XmNiconMask, pm->mask, NULL);} // End UpdateTitle/*--------------------------------------------------------------- *  Method to set buttons sensitivities */voidMainWinC::EnableButtons(){   if ( ishApp->exiting || !curFolder || !curFolder->active ) return;#if 1//// Get the list and count of messages//   VItemListC&	msgList = priv->msgVBox->VisItems();   unsigned	msgCount = msgList.size();//// Get the list and count of selected messages//   VItemListC&	selList = priv->msgTBox->get_selected();   unsigned	selCount = selList.size();//// Get the number of selected folders//   unsigned	folderSelCount = priv->folderVBox->SelItems().size();   unsigned	folderCount    = priv->folderVBox->Items().size();//// See if changes have been made to the current folder//   Boolean saveNeeded = (curFolder->writable && curFolder->Changed());//// See if there are any changed folders//   Boolean anyReadOnly = !ishApp->systemFolder->writable;   Boolean anyChanged  = saveNeeded || ishApp->systemFolder->Changed();   Boolean selReadOnly = False;   Boolean selChanged  = False;   unsigned	count = ishApp->folderPrefs->OpenFolders().size();   int	i;   for (i=0; i<count; i++) {      FolderC	*folder = ishApp->folderPrefs->OpenFolders()[i];      VItemC	*icon   = folder->icon;      if ( folder->isInBox || folder == curFolder ) continue;      if ( !anyReadOnly ) 	 anyReadOnly = !folder->writable;      Boolean	thisSelected = priv->folderVBox->SelItems().includes(icon);      if ( !selReadOnly ) 	 selReadOnly = (thisSelected && !folder->writable);      Boolean	thisChanged = (folder->writable && folder->Changed());      if ( !anyChanged ) 	 anyChanged = thisChanged;      if ( !selChanged )	 selChanged = (thisChanged && thisSelected);   }   if ( anyReadOnly ) anyChanged = False;   if ( selReadOnly ) selChanged = False;//// Count the number of deleted items in the current folder//   unsigned	delCount = curFolder->DelItemList().size();//// Count the number of deleted items that are selected//   unsigned	delSelCount = 0;   if ( curFolder->writable ) {      for (i=0; i<selCount; i++) {	 MsgItemC	*item = (MsgItemC*)selList[i];	 if ( item->IsDeleted() ) delSelCount++;      }   }//// Update buttons sensitivities based on number of selected items//   XtSetSensitive(priv->filePrintPB, selCount>0 && delSelCount==0);   XtSetSensitive(priv->folderOpenRecentCB,   		  ishApp->appPrefs->recentFolders.size()>0);   XtSetSensitive(priv->folderActSysPB,    !curFolder->isInBox);   XtSetSensitive(priv->folderActSelPB,    folderSelCount==1);   XtSetSensitive(priv->folderSaveCurPB,   saveNeeded);   XtSetSensitive(priv->folderSaveSelPB,   selChanged);   XtSetSensitive(priv->folderSaveAllPB,   anyChanged);   XtSetSensitive(priv->folderReadSelPB,   folderSelCount>0);   XtSetSensitive(priv->folderCloseCurPB,  !curFolder->isInBox);   XtSetSensitive(priv->folderCloseSelPB,  folderSelCount>0);   XtSetSensitive(priv->folderCloseAllPB,  folderCount>1);   XtSetSensitive(priv->folderDelCurPB,   		  !curFolder->isInBox && curFolder->writable);   XtSetSensitive(priv->folderDelSelPB,    folderSelCount>0 && !selReadOnly);   XtSetSensitive(priv->folderDelAllPB,    folderCount>1    && !anyReadOnly);   XtSetSensitive(priv->folderSelPB,       folderSelCount<folderCount);   XtSetSensitive(priv->folderDeselPB,     folderSelCount>0);   XtSetSensitive(priv->msgReplyPB,       selCount==1);   XtSetSensitive(priv->msgReplyAllPB,    selCount==1);   XtSetSensitive(priv->msgReplyIncPB,    selCount==1);   XtSetSensitive(priv->msgReplyAllIncPB, selCount==1);   XtSetSensitive(priv->msgForwardPB,     selCount>0);   XtSetSensitive(priv->msgForward822PB,  selCount>0);   XtSetSensitive(priv->msgResendPB,      selCount>0);   XtSetSensitive(priv->msgReadPB,        selCount>0);   XtSetSensitive(priv->msgSavePB,        selCount>0);   XtSetSensitive(priv->msgSavePatPB,     selCount>0);   XtSetSensitive(priv->msgSaveSelPB,     selCount>0 && folderSelCount>0);   XtSetSensitive(priv->msgSaveToPB,      selCount>0);   XtSetSensitive(priv->msgSaveToFilePB,  selCount>0);   XtSetSensitive(priv->msgSaveRecentCB,		  selCount>0 && ishApp->appPrefs->recentFolders.size()>0);   XtSetSensitive(priv->msgSaveQuickCB,   selCount>0);   XtSetSensitive(priv->msgPrintPB,       selCount>0);   XtSetSensitive(priv->msgPipePB,        selCount>0);   XtSetSensitive(priv->msgStatCB,        curFolder->writable && selCount>0);   XtSetSensitive(priv->msgDelPB,   		  curFolder->writable && selCount>delSelCount);   XtSetSensitive(priv->msgUndelLastPB,   priv->lastDelList->size()>0);   XtSetSensitive(priv->msgUndelSelPB,   		  !ishApp->appPrefs->hideDeleted && delSelCount>0);   XtSetSensitive(priv->msgUndelListPB,   		  ishApp->appPrefs->hideDeleted && delCount>0);   XtSetSensitive(priv->msgSelPB,         selCount<msgCount);   XtSetSensitive(priv->msgDeselPB,       selCount>0);   XtSetSensitive(priv->msgFindPB,        msgCount>0);//// See if the next or previous buttons can be used.//   if ( curMsgList->size()==1 || selCount==1 ) {      MsgItemC *msgItem = (MsgItemC*)(curMsgList->size()==1 ? (*curMsgList)[0]							    : selList[0]);      MsgC	*msg = msgItem->msg;      XtSetSensitive(priv->msgNextPB,        NextReadable(msg) != NULL);      XtSetSensitive(priv->msgNextUnreadPB,  NextUnread  (msg) != NULL);      XtSetSensitive(priv->msgNextSenderPB,  NextSender  (msg) != NULL);      XtSetSensitive(priv->msgNextSubjectPB, NextSubject (msg) != NULL);      XtSetSensitive(priv->msgPrevPB,        PrevReadable(msg) != NULL);      XtSetSensitive(priv->msgPrevUnreadPB,  PrevUnread  (msg) != NULL);      XtSetSensitive(priv->msgPrevSenderPB,  PrevSender  (msg) != NULL);      XtSetSensitive(priv->msgPrevSubjectPB, PrevSubject (msg) != NULL);   } // End if one message is selected or displayed   else {      XtSetSensitive(priv->msgNextPB,        False);      XtSetSensitive(priv->msgNextUnreadPB,  False);      XtSetSensitive(priv->msgNextSenderPB,  False);      XtSetSensitive(priv->msgNextSubjectPB, False);      XtSetSensitive(priv->msgPrevPB,        False);      XtSetSensitive(priv->msgPrevUnreadPB,  False);      XtSetSensitive(priv->msgPrevSenderPB,  False);      XtSetSensitive(priv->msgPrevSubjectPB, False);      XtSetSensitive(priv->msgPrevPB,        False);   }#else//// Update buttons sensitivities based on number of selected items//   XtSetSensitive(priv->filePrintPB, True);   XtSetSensitive(priv->folderOpenRecentCB, True);   XtSetSensitive(priv->folderActSysPB,    True);   XtSetSensitive(priv->folderActSelPB,    True);   XtSetSensitive(priv->folderSaveCurPB,   True);   XtSetSensitive(priv->folderSaveSelPB,   True);   XtSetSensitive(priv->folderSaveAllPB,   True);   XtSetSensitive(priv->folderReadSelPB,   True);   XtSetSensitive(priv->folderCloseCurPB,  True);   XtSetSensitive(priv->folderCloseSelPB,  True);   XtSetSensitive(priv->folderCloseAllPB,  True);   XtSetSensitive(priv->folderDelCurPB,	True);   XtSetSensitive(priv->folderDelSelPB,    True);   XtSetSensitive(priv->folderDelAllPB,    True);   XtSetSensitive(priv->folderSelPB,       True);   XtSetSensitive(priv->folderDeselPB,     True);   XtSetSensitive(priv->msgReplyPB,       True);   XtSetSensitive(priv->msgReplyAllPB,    True);   XtSetSensitive(priv->msgReplyIncPB,    True);   XtSetSensitive(priv->msgReplyAllIncPB, True);   XtSetSensitive(priv->msgForwardPB,     True);   XtSetSensitive(priv->msgForward822PB,  True);   XtSetSensitive(priv->msgResendPB,      True);   XtSetSensitive(priv->msgReadPB,        True);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -