00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TROOT.h"
00013 #include "TApplication.h"
00014 #include "TSystem.h"
00015 #include "TGMenu.h"
00016 #include "TGComboBox.h"
00017 #include "TGFrame.h"
00018 #include "TGButton.h"
00019 #include "TGTextBuffer.h"
00020 #include "TGTextEntry.h"
00021 #include "TGStatusBar.h"
00022 #include "TGFileDialog.h"
00023 #include "TFile.h"
00024 #include "TBrowser.h"
00025 #include "TGHtml.h"
00026 #include "TString.h"
00027 #include "TUrl.h"
00028 #include "TSocket.h"
00029 #include "Riostream.h"
00030 #include "TGHtmlBrowser.h"
00031 #include "TGText.h"
00032
00033 #ifdef WIN32
00034 #include "TWin32SplashThread.h"
00035 #endif
00036
00037 #include <stdlib.h>
00038
00039
00040
00041
00042
00043
00044
00045
00046 ClassImp(TGHtmlBrowser)
00047
00048 enum EMyMessageTypes {
00049 kM_FILE_OPEN,
00050 kM_FILE_SAVEAS,
00051 kM_FILE_BROWSE,
00052 kM_FILE_EXIT,
00053 kM_FAVORITES_ADD,
00054 kM_TOOLS_CLEARHIST,
00055 kM_HELP_ABOUT
00056 };
00057
00058 static const char *gHtmlFTypes[] = {
00059 "HTML files", "*.htm*",
00060 "All files", "*",
00061 0, 0
00062 };
00063
00064 const char *HtmlError[] = {
00065 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\"> ",
00066 "<HTML><HEAD><TITLE>RHTML cannot display the webpage</TITLE> ",
00067 "<META http-equiv=Content-Type content=\"text/html; charset=UTF-8\"></HEAD> ",
00068 "<BODY> ",
00069 "<TABLE cellSpacing=0 cellPadding=0 width=730 border=0> ",
00070 " <TBODY> ",
00071 " <TR> ",
00072 " <TD id=infoIconAlign vAlign=top align=left width=60 rowSpan=2> ",
00073 " <IMG src=\"info.gif\"> ",
00074 " </TD> ",
00075 " <TD id=mainTitleAlign vAlign=center align=left width=*> ",
00076 " <H1 id=mainTitle>RHTML cannot display the webpage</H1></TD></TR> ",
00077 " <TR> ",
00078 " <TD class=errorCodeAndDivider id=errorCodeAlign align=right> ",
00079 " <DIV class=divider></DIV></TD></TR> ",
00080 " <TR> ",
00081 " <UL> ",
00082 " </UL> ",
00083 " <TD> </TD> ",
00084 " <TD id=MostLikelyAlign vAlign=top align=left> ",
00085 " <H3 id=likelyCauses>Most likely causes:</H3> ",
00086 " <UL> ",
00087 " <LI id=causeNotConnected>You are not connected to the Internet. ",
00088 " <LI id=causeSiteProblem>The website is encountering problems. ",
00089 " <LI id=causeErrorInAddress>There might be a typing error in the address. ",
00090 " <LI id=causeOtherError> ",
00091 " </LI></UL></TD></TR> ",
00092 " <TR> ",
00093 " <TD id=infoBlockAlign vAlign=top align=right> </TD> ",
00094 " <TD id=moreInformationAlign vAlign=center align=left> ",
00095 " <H4> ",
00096 " <TABLE> ",
00097 " <TBODY> ",
00098 " <TR> ",
00099 " <TD vAlign=top><SPAN id=moreInfoContainer></SPAN><ID ",
00100 " id=moreInformation>More information</ID> ",
00101 " </TD></TR></TBODY></TABLE></H4> ",
00102 " <DIV class=infoBlock id=infoBlockID> ",
00103 " <P><ID id=errorExpl1>This problem can be caused by a variety of issues, ",
00104 " including:</ID> ",
00105 " <UL> ",
00106 " <LI id=errorExpl2>Internet connectivity has been lost. ",
00107 " <LI id=errorExpl3>The website is temporarily unavailable. ",
00108 " <LI id=errorExpl4>The Domain Name Server (DNS) is not reachable. ",
00109 " <LI id=errorExpl5>The Domain Name Server (DNS) does not have a listing ",
00110 " for the website's domain. ",
00111 " <P></P> ",
00112 " <P></P></DIV></TD></TR></TBODY></TABLE></BODY></HTML> ",
00113 0
00114 };
00115
00116
00117 TGHtmlBrowser::TGHtmlBrowser(const char *filename, const TGWindow *p, UInt_t w, UInt_t h)
00118 : TGMainFrame(p, w, h)
00119 {
00120
00121
00122 SetCleanup(kDeepCleanup);
00123 fNbFavorites = 1000;
00124 fMenuBar = new TGMenuBar(this, 35, 50, kHorizontalFrame);
00125
00126 fMenuFile = new TGPopupMenu(gClient->GetDefaultRoot());
00127 fMenuFile->AddEntry(" &Open...\tCtrl+O", kM_FILE_OPEN, 0,
00128 gClient->GetPicture("ed_open.png"));
00129 fMenuFile->AddEntry(" Save &As...\tCtrl+A", kM_FILE_SAVEAS, 0,
00130 gClient->GetPicture("ed_save.png"));
00131 fMenuFile->AddEntry(" &Browse...\tCtrl+B", kM_FILE_BROWSE);
00132 fMenuFile->AddSeparator();
00133 fMenuFile->AddEntry(" E&xit\tCtrl+Q", kM_FILE_EXIT, 0,
00134 gClient->GetPicture("bld_exit.png"));
00135 fMenuFile->Associate(this);
00136
00137 fMenuFavorites = new TGPopupMenu(gClient->GetDefaultRoot());
00138 fMenuFavorites->AddEntry("&Add to Favorites", kM_FAVORITES_ADD, 0,
00139 gClient->GetPicture("bld_plus.png"));
00140 fMenuFavorites->AddSeparator();
00141 fMenuFavorites->AddEntry("http://root.cern.ch", fNbFavorites++, 0,
00142 gClient->GetPicture("htmlfile.gif"));
00143 fMenuFavorites->Associate(this);
00144
00145 fMenuTools = new TGPopupMenu(gClient->GetDefaultRoot());
00146 fMenuTools->AddEntry("&Clear History", kM_TOOLS_CLEARHIST, 0,
00147 gClient->GetPicture("ed_delete.png"));
00148 fMenuTools->Associate(this);
00149
00150 fMenuHelp = new TGPopupMenu(gClient->GetDefaultRoot());
00151 fMenuHelp->AddEntry(" &About...", kM_HELP_ABOUT, 0, gClient->GetPicture("about.xpm"));
00152 fMenuHelp->Associate(this);
00153
00154 fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
00155 fMenuBar->AddPopup("&Favorites", fMenuFavorites, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
00156 fMenuBar->AddPopup("&Tools", fMenuTools, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
00157 fMenuBar->AddPopup("&Help", fMenuHelp, new TGLayoutHints(kLHintsTop | kLHintsRight));
00158
00159 AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
00160
00161
00162 fVerticalFrame = new TGVerticalFrame(this,727,600,kVerticalFrame);
00163
00164 fHorizontalFrame = new TGHorizontalFrame(fVerticalFrame,727,600);
00165
00166 fBack = new TGPictureButton(fHorizontalFrame,gClient->GetPicture("GoBack.gif"));
00167 fBack->SetToolTipText("Go Back");
00168 fHorizontalFrame->AddFrame(fBack, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY,2,2,2,2));
00169 fBack->Connect("Clicked()", "TGHtmlBrowser", this, "Back()");
00170
00171 fForward = new TGPictureButton(fHorizontalFrame,gClient->GetPicture("GoForward.gif"));
00172 fForward->SetToolTipText("Go Forward");
00173 fHorizontalFrame->AddFrame(fForward, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY,2,2,2,2));
00174 fForward->Connect("Clicked()", "TGHtmlBrowser", this, "Forward()");
00175
00176 fReload = new TGPictureButton(fHorizontalFrame,gClient->GetPicture("ReloadPage.gif"));
00177 fReload->SetToolTipText("Reload Page");
00178 fHorizontalFrame->AddFrame(fReload, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY,2,2,2,2));
00179 fReload->Connect("Clicked()", "TGHtmlBrowser", this, "Reload()");
00180
00181 fStop = new TGPictureButton(fHorizontalFrame,gClient->GetPicture("StopLoading.gif"));
00182 fStop->SetToolTipText("Stop Loading");
00183 fHorizontalFrame->AddFrame(fStop, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY,2,2,2,2));
00184 fStop->Connect("Clicked()", "TGHtmlBrowser", this, "Stop()");
00185
00186 fHome = new TGPictureButton(fHorizontalFrame,gClient->GetPicture("GoHome.gif"));
00187 fHome->SetToolTipText("Go to ROOT HomePage\n (http://root.cern.ch)");
00188 fHorizontalFrame->AddFrame(fHome, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY,2,2,2,2));
00189 fHome->Connect("Clicked()", "TGHtmlBrowser", this, "Selected(=\"http://root.cern.ch\")");
00190
00191
00192 fURLBuf = new TGTextBuffer(256);
00193 fComboBox = new TGComboBox(fHorizontalFrame, "");
00194 fURL = fComboBox->GetTextEntry();
00195 fURLBuf = fURL->GetBuffer();
00196 fComboBox->Resize(200, fURL->GetDefaultHeight());
00197 fURL->Connect("ReturnPressed()", "TGHtmlBrowser", this, "URLChanged()");
00198
00199 fComboBox->AddEntry(filename,1);
00200 fURL->SetText(filename);
00201
00202 fComboBox->Select(0);
00203 fComboBox->Connect("Selected(char *)", "TGHtmlBrowser", this, "Selected(char *)");
00204
00205 fHorizontalFrame->AddFrame(fComboBox, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
00206
00207 fVerticalFrame->AddFrame(fHorizontalFrame, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX,2,2,2,2));
00208
00209
00210 fHtml = new TGHtml(fVerticalFrame, 10, 10, -1);
00211 fVerticalFrame->AddFrame(fHtml, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX | kLHintsExpandY,2,2,2,2));
00212
00213 AddFrame(fVerticalFrame, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX | kLHintsExpandY,2,2,2,2));
00214
00215
00216 fStatusBar = new TGStatusBar(this,100,20);
00217 Int_t partsusBar[] = {75,25};
00218 fStatusBar->SetParts(partsusBar,2);
00219 AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom | kLHintsExpandX));
00220
00221 fHtml->Connect("MouseOver(const char *)", "TGHtmlBrowser", this, "MouseOver(const char *)");
00222 fHtml->Connect("MouseDown(const char *)", "TGHtmlBrowser", this, "MouseDown(const char *)");
00223
00224 MapSubwindows();
00225 Resize(GetDefaultSize());
00226 MapWindow();
00227 Resize(w, h);
00228
00229 if (filename)
00230 Selected(filename);
00231 }
00232
00233
00234 Ssiz_t ReadSize(const char *url)
00235 {
00236
00237
00238 char buf[4096];
00239 TUrl fUrl(url);
00240
00241
00242 TString msg = "HEAD ";
00243 msg += fUrl.GetProtocol();
00244 msg += "://";
00245 msg += fUrl.GetHost();
00246 msg += ":";
00247 msg += fUrl.GetPort();
00248 msg += "/";
00249 msg += fUrl.GetFile();
00250 msg += " HTTP/1.0";
00251 msg += "\r\n";
00252 msg += "User-Agent: ROOT-TWebFile/1.1";
00253 msg += "\r\n\r\n";
00254
00255 TString uri(url);
00256 if (!uri.BeginsWith("http://"))
00257 return 0;
00258 TSocket s(fUrl.GetHost(), fUrl.GetPort());
00259 if (!s.IsValid())
00260 return 0;
00261 if (s.SendRaw(msg.Data(), msg.Length()) == -1)
00262 return 0;
00263 if (s.RecvRaw(buf, 4096) == -1) {
00264 return 0;
00265 }
00266 TString reply(buf);
00267 Ssiz_t idx = reply.Index("Content-length:", 0, TString::kIgnoreCase);
00268 if (idx > 0) {
00269 idx += 15;
00270 TString slen = reply(idx, reply.Length() - idx);
00271 return (Ssiz_t)atol(slen.Data());
00272 }
00273 return 0;
00274 }
00275
00276
00277 static char *ReadRemote(const char *url)
00278 {
00279
00280
00281 static char *buf = 0;
00282 TUrl fUrl(url);
00283
00284 Ssiz_t size = ReadSize(url);
00285 if (size <= 0) size = 1024*1024;
00286
00287 TString msg = "GET ";
00288 msg += fUrl.GetProtocol();
00289 msg += "://";
00290 msg += fUrl.GetHost();
00291 msg += ":";
00292 msg += fUrl.GetPort();
00293 msg += "/";
00294 msg += fUrl.GetFile();
00295 msg += "\r\n";
00296
00297 TString uri(url);
00298 if (!uri.BeginsWith("http://"))
00299 return 0;
00300 TSocket s(fUrl.GetHost(), fUrl.GetPort());
00301 if (!s.IsValid())
00302 return 0;
00303 if (s.SendRaw(msg.Data(), msg.Length()) == -1)
00304 return 0;
00305 buf = (char *)calloc(size+1, sizeof(char));
00306 if (s.RecvRaw(buf, size) == -1) {
00307 free(buf);
00308 return 0;
00309 }
00310 return buf;
00311 }
00312
00313
00314 void TGHtmlBrowser::Selected(const char *uri)
00315 {
00316
00317
00318 char *buf = 0;
00319 FILE *f;
00320
00321 if (CheckAnchors(uri))
00322 return;
00323
00324 TString surl(gSystem->UnixPathName(uri));
00325 if (!surl.BeginsWith("http://") && !surl.BeginsWith("ftp://") &&
00326 !surl.BeginsWith("file://")) {
00327 if (surl.BeginsWith("file:"))
00328 surl.ReplaceAll("file:", "file://");
00329 else
00330 surl.Prepend("file://");
00331 }
00332 if (surl.EndsWith(".root")) {
00333
00334 gVirtualX->SetCursor(fHtml->GetId(), gVirtualX->CreateCursor(kWatch));
00335 gROOT->ProcessLine(Form("TFile::Open(\"%s\");", surl.Data()));
00336 Clicked((char *)surl.Data());
00337 gROOT->RefreshBrowsers();
00338 gVirtualX->SetCursor(fHtml->GetId(), gVirtualX->CreateCursor(kPointer));
00339 return;
00340 }
00341 gVirtualX->SetCursor(fHtml->GetId(), gVirtualX->CreateCursor(kWatch));
00342 TUrl url(surl.Data());
00343 if (surl.EndsWith(".pdf", TString::kIgnoreCase)) {
00344
00345
00346 if (!gVirtualX->InheritsFrom("TGX11")) {
00347 TString cmd = TString::Format("explorer %s", surl.Data());
00348 gSystem->Exec(cmd.Data());
00349 }
00350 gVirtualX->SetCursor(fHtml->GetId(), gVirtualX->CreateCursor(kPointer));
00351 return;
00352 }
00353 if (surl.EndsWith(".gif") || surl.EndsWith(".jpg") || surl.EndsWith(".png")) {
00354
00355 fHtml->Clear();
00356 char imgHtml[1024];
00357 snprintf(imgHtml, 1000, "<IMG src=\"%s\"> ", surl.Data());
00358 fHtml->ParseText(imgHtml);
00359 fHtml->SetBaseUri(url.GetUrl());
00360 fURL->SetText(surl.Data());
00361 if (!fComboBox->FindEntry(surl.Data()))
00362 fComboBox->AddEntry(surl.Data(), fComboBox->GetNumberOfEntries()+1);
00363 fHtml->Layout();
00364 gVirtualX->SetCursor(fHtml->GetId(), gVirtualX->CreateCursor(kPointer));
00365 return;
00366 }
00367 if ((!strcmp(url.GetProtocol(), "http"))) {
00368
00369 buf = ReadRemote(url.GetUrl());
00370 if (buf) {
00371 fHtml->Clear();
00372 fHtml->Layout();
00373 fHtml->SetBaseUri(url.GetUrl());
00374 fHtml->ParseText(buf);
00375 free(buf);
00376 fURL->SetText(surl.Data());
00377 if (!fComboBox->FindEntry(surl.Data()))
00378 fComboBox->AddEntry(surl.Data(), fComboBox->GetNumberOfEntries()+1);
00379 }
00380 else {
00381 fHtml->Clear();
00382 fHtml->Layout();
00383 fHtml->SetBaseUri("");
00384 for (int i=0; HtmlError[i]; i++) {
00385 fHtml->ParseText((char *)HtmlError[i]);
00386 }
00387 }
00388 }
00389 else {
00390
00391 f = fopen(url.GetFile(), "r");
00392 if (f) {
00393 TString fpath = url.GetUrl();
00394 fpath.ReplaceAll(gSystem->BaseName(fpath.Data()), "");
00395 fpath.ReplaceAll("file://", "");
00396 fHtml->Clear();
00397 fHtml->Layout();
00398 fHtml->SetBaseUri(fpath.Data());
00399 buf = (char *)calloc(4096, sizeof(char));
00400 while (fgets(buf, 4096, f)) {
00401 fHtml->ParseText(buf);
00402 }
00403 free(buf);
00404 fclose(f);
00405 fURL->SetText(surl.Data());
00406 if (!fComboBox->FindEntry(surl.Data()))
00407 fComboBox->AddEntry(surl.Data(), fComboBox->GetNumberOfEntries()+1);
00408 }
00409 else {
00410 fHtml->Clear();
00411 fHtml->Layout();
00412 fHtml->SetBaseUri("");
00413 for (int i=0; HtmlError[i]; i++) {
00414 fHtml->ParseText((char *)HtmlError[i]);
00415 }
00416 }
00417 }
00418
00419 gVirtualX->SetCursor(fHtml->GetId(), gVirtualX->CreateCursor(kPointer));
00420 fHtml->Layout();
00421 Ssiz_t idx = surl.Last('#');
00422 if (idx > 0) {
00423 idx +=1;
00424 TString anchor = surl(idx, surl.Length() - idx);
00425 fHtml->GotoAnchor(anchor.Data());
00426 }
00427 SetWindowName(Form("%s - RHTML",surl.Data()));
00428 }
00429
00430
00431 void TGHtmlBrowser::URLChanged()
00432 {
00433
00434
00435 const char *string = fURL->GetText();
00436 if (string) {
00437 Selected(gSystem->UnixPathName(string));
00438 }
00439 }
00440
00441
00442 void TGHtmlBrowser::Back()
00443 {
00444
00445
00446 Int_t index = 0;
00447 const char *string = fURL->GetText();
00448 TGLBEntry * lbe1 = fComboBox->FindEntry(string);
00449 if (lbe1)
00450 index = lbe1->EntryId();
00451 if (index > 0) {
00452 fComboBox->Select(index - 1, kTRUE);
00453 TGTextLBEntry *entry = (TGTextLBEntry *)fComboBox->GetSelectedEntry();
00454 if (entry) {
00455 string = entry->GetTitle();
00456 if (string)
00457 Selected(string);
00458 }
00459 }
00460 }
00461
00462
00463 Bool_t TGHtmlBrowser::CheckAnchors(const char *uri)
00464 {
00465
00466
00467
00468 TString surl(gSystem->UnixPathName(uri));
00469
00470 if (!fHtml->GetBaseUri())
00471 return kFALSE;
00472 TString actual = fHtml->GetBaseUri();
00473 Ssiz_t idx = surl.Last('#');
00474 Ssiz_t idy = actual.Last('#');
00475 TString short1(surl.Data());
00476 TString short2(actual.Data());
00477 if (idx > 0)
00478 short1 = surl(0, idx);
00479 if (idy > 0)
00480 short2 = actual(0, idy);
00481
00482 if (short1 == short2) {
00483 if (idx > 0) {
00484 idx +=1;
00485 TString anchor = surl(idx, surl.Length() - idx);
00486 fHtml->GotoAnchor(anchor.Data());
00487 }
00488 else {
00489 fHtml->ScrollToPosition(TGLongPosition(0, 0));
00490 }
00491 fHtml->SetBaseUri(surl.Data());
00492 if (!fComboBox->FindEntry(surl.Data()))
00493 fComboBox->AddEntry(surl.Data(), fComboBox->GetNumberOfEntries()+1);
00494 fURL->SetText(surl.Data());
00495 fComboBox->Select(fComboBox->GetNumberOfEntries(), kFALSE);
00496 SetWindowName(Form("%s - RHTML",surl.Data()));
00497 return kTRUE;
00498 }
00499 return kFALSE;
00500 }
00501
00502
00503 void TGHtmlBrowser::Forward()
00504 {
00505
00506
00507 Int_t index = 0;
00508 const char *string = fURL->GetText();
00509 TGLBEntry * lbe1 = fComboBox->FindEntry(string);
00510 if (lbe1)
00511 index = lbe1->EntryId();
00512 if (index < fComboBox->GetNumberOfEntries()) {
00513 fComboBox->Select(index + 1, kTRUE);
00514 TGTextLBEntry *entry = (TGTextLBEntry *)fComboBox->GetSelectedEntry();
00515 if (entry) {
00516 string = entry->GetTitle();
00517 if (string)
00518 Selected(string);
00519 }
00520 }
00521 }
00522
00523
00524 void TGHtmlBrowser::Reload()
00525 {
00526
00527
00528 const char *string = fURL->GetText();
00529 if (string)
00530 Selected(string);
00531 }
00532
00533
00534 void TGHtmlBrowser::Stop()
00535 {
00536
00537
00538 }
00539
00540
00541 void TGHtmlBrowser::MouseOver(const char *url)
00542 {
00543
00544
00545 fStatusBar->SetText(url, 0);
00546 }
00547
00548
00549 void TGHtmlBrowser::MouseDown(const char *url)
00550 {
00551
00552
00553 Selected(url);
00554 }
00555
00556
00557 Bool_t TGHtmlBrowser::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
00558 {
00559
00560
00561 switch (GET_MSG(msg)) {
00562 case kC_COMMAND:
00563 {
00564 switch (GET_SUBMSG(msg)) {
00565
00566 case kCM_MENU:
00567 case kCM_BUTTON:
00568
00569 switch(parm1) {
00570
00571 case kM_FILE_EXIT:
00572 CloseWindow();
00573 break;
00574
00575 case kM_FILE_OPEN:
00576 {
00577 static TString dir(".");
00578 TGFileInfo fi;
00579 fi.fFileTypes = gHtmlFTypes;
00580 fi.fIniDir = StrDup(dir);
00581 new TGFileDialog(fClient->GetRoot(), this,
00582 kFDOpen, &fi);
00583 dir = fi.fIniDir;
00584 if (fi.fFilename) {
00585 Selected(Form("file://%s",
00586 gSystem->UnixPathName(fi.fFilename)));
00587 }
00588 }
00589 break;
00590
00591 case kM_FILE_SAVEAS:
00592 {
00593 static TString sdir(".");
00594 TGFileInfo fi;
00595 fi.fFileTypes = gHtmlFTypes;
00596 fi.fIniDir = StrDup(sdir);
00597 new TGFileDialog(fClient->GetRoot(), this,
00598 kFDSave, &fi);
00599 sdir = fi.fIniDir;
00600 if (fi.fFilename) {
00601 TGText txt(fHtml->GetText());
00602 txt.Save(gSystem->UnixPathName(fi.fFilename));
00603 }
00604 }
00605 break;
00606
00607 case kM_FAVORITES_ADD:
00608 fMenuFavorites->AddEntry(Form("%s",
00609 fURL->GetText()), fNbFavorites++, 0,
00610 gClient->GetPicture("htmlfile.gif"));
00611 break;
00612
00613 case kM_TOOLS_CLEARHIST:
00614 fComboBox->RemoveEntries(1,fComboBox->GetNumberOfEntries());
00615 break;
00616
00617 case kM_FILE_BROWSE:
00618 new TBrowser();
00619 break;
00620
00621 case kM_HELP_ABOUT:
00622 {
00623 #ifdef R__UNIX
00624 TString rootx;
00625 # ifdef ROOTBINDIR
00626 rootx = ROOTBINDIR;
00627 # else
00628 rootx = gSystem->Getenv("ROOTSYS");
00629 if (!rootx.IsNull()) rootx += "/bin";
00630 # endif
00631 rootx += "/root -a &";
00632 gSystem->Exec(rootx);
00633 #else
00634 #ifdef WIN32
00635 new TWin32SplashThread(kTRUE);
00636 #else
00637 char str[32];
00638 sprintf(str, "About ROOT %s...", gROOT->GetVersion());
00639 TRootHelpDialog *hd = new TRootHelpDialog(this, str,
00640 600, 400);
00641 hd->SetText(gHelpAbout);
00642 hd->Popup();
00643 #endif
00644 #endif
00645 }
00646 break;
00647
00648 default:
00649 {
00650 if (parm1 < 1000) break;
00651 TGMenuEntry *entry = fMenuFavorites->GetEntry(parm1);
00652 if (!entry) break;
00653 const char *shortcut = entry->GetName();
00654 if (shortcut)
00655 Selected(shortcut);
00656 }
00657 break;
00658 }
00659 break;
00660 }
00661 break;
00662 }
00663 }
00664 return kTRUE;
00665 }
00666