Clear dropdown history in location bar when the user clears the history (in Prefs). Bug #114674 (P1 & TS1). This change also keeps all the dropdown lists in sync.

This commit is contained in:
slamm%netscape.com 1998-07-24 00:19:21 +00:00
parent 15773141e7
commit 8c731c9fd7
5 changed files with 99 additions and 7 deletions

View File

@ -75,6 +75,8 @@ const char *XFE_MozillaApp::defaultColorsChanged = "XFE_MozillaApp::defaultColor
const char *XFE_MozillaApp::defaultFontChanged = "XFE_MozillaApp::defaultFontChanged";
const char *XFE_MozillaApp::refreshMsgWindow = "XFE_MozillaApp::refreshMsgWindow";
const char *XFE_MozillaApp::personalToolbarFolderChanged = "XFE_MozillaApp::personalToolbarFolderChanged";
const char *XFE_MozillaApp::addURLtoURLBarHistory = "XFE_MozillaApp::addURLtoURLBarHistory";
const char *XFE_MozillaApp::clearURLBarHistory = "XFE_MozillaApp::clearURLBarHistory";
static void xfeDoCommandAction(Widget w, XEvent *, String *, Cardinal *);
static void xfeDoTextAction(Widget w, XEvent *, String *, Cardinal *);

View File

@ -66,6 +66,8 @@ public:
static const char *defaultFontChanged;
static const char *refreshMsgWindow;
static const char *personalToolbarFolderChanged;
static const char *addURLtoURLBarHistory;
static const char *clearURLBarHistory;
// called when a registered frame is being destroyed.
XFE_CALLBACK_DECL(frameUnregistering)

View File

@ -25,6 +25,7 @@
#include "fonts.h"
#include "xpassert.h"
#include "MozillaApp.h"
#include "URLBar.h" // for interface to clear URLBar
#include "View.h"
#include "xfe.h"
#include "e_kit.h"
@ -638,6 +639,7 @@ void XFE_PrefsPageBrowser::cb_expireNow(Widget /* widget */,
if (XFE_Confirm(fep->context, fe_globalData.expire_now_message)) {
GH_ClearGlobalHistory();
fe_RefreshAllAnchors();
XFE_URLBar::clearAll();
}
}

View File

@ -452,6 +452,16 @@ XFE_URLBar::createUrlComboBox(Widget parent,History_entry * first_entry)
XmNactivateCallback,
url_text_cb,
(XtPointer) this);
XFE_MozillaApp::theApp()->registerInterest(
XFE_MozillaApp::addURLtoURLBarHistory,
this,
(XFE_FunctionNotification)_recordURL_cb);
XFE_MozillaApp::theApp()->registerInterest(
XFE_MozillaApp::clearURLBarHistory,
this,
(XFE_FunctionNotification)_clearAll_cb);
}
//////////////////////////////////////////////////////////////////////////
XFE_URLBar::~XFE_URLBar()
@ -477,6 +487,14 @@ XFE_URLBar::~XFE_URLBar()
m_bookmarkDropSite = NULL;
}
XFE_MozillaApp::theApp()->unregisterInterest(
XFE_MozillaApp::addURLtoURLBarHistory,
this,
(XFE_FunctionNotification)_recordURL_cb);
XFE_MozillaApp::theApp()->unregisterInterest(
XFE_MozillaApp::clearURLBarHistory,
this,
(XFE_FunctionNotification)_clearAll_cb);
}
//////////////////////////////////////////////////////////////////////////
Widget
@ -505,6 +523,17 @@ XFE_URLBar::getFormWidget()
//////////////////////////////////////////////////////////////////////////
void
XFE_URLBar::recordURL(URL_Struct *url)
{
if ( !url->address ) return;
// Notify all frames to add this URL
XFE_MozillaApp::theApp()->notifyInterested(XFE_MozillaApp::addURLtoURLBarHistory,(void*)url);
/* Save to history */
saveUserHistory();
}
//////////////////////////////////////////////////////////////////////////
XFE_CALLBACK_DEFN(XFE_URLBar, _recordURL)(XFE_NotificationCenter*, void*, void* callData)
{
XmString str;
int itemCount = 0;
@ -513,7 +542,8 @@ XFE_URLBar::recordURL(URL_Struct *url)
int poscnt;
Boolean found = False;
if ( !url->address ) return;
URL_Struct *url = (URL_Struct*)callData;
str = XmStringCreateLtoR(url->address, XmSTRING_DEFAULT_CHARSET);
XtVaGetValues(m_urlComboBox, XmNlist, &list, 0);
@ -533,11 +563,8 @@ XFE_URLBar::recordURL(URL_Struct *url)
XmListSelectPos(list, 1, False);
XmListSetPos(list, 1); /* Scroll to top */
}
/* Save to history */
saveUserHistory();
}
}
//////////////////////////////////////////////////////////////////////////
void
XFE_URLBar::setURLString(URL_Struct *url)
{
@ -602,8 +629,41 @@ XFE_URLBar::setURLString(URL_Struct *url)
fe_store_url_prop(context, url);
#endif /* notyet */
}
//////////////////////////////////////////////////////////////////////////
/*static*/
void
XFE_URLBar::clearAll()
{
// Notify all frames to clear the URLBar (handled by _clearAll below)
XFE_MozillaApp::theApp()->notifyInterested(XFE_MozillaApp::clearURLBarHistory, NULL);
eraseUserHistory();
}
//////////////////////////////////////////////////////////////////////////
XFE_CALLBACK_DEFN(XFE_URLBar, _clearAll)(XFE_NotificationCenter*, void*, void*)
{
XP_ASSERT(m_urlComboBox);
Widget text_field;
char * text;
// Toss out the combo list,
// but save the text in the textfield
XtVaGetValues (m_urlComboBox, XmNtextField, &text_field, 0);
XP_ASSERT(text_field);
text = fe_GetTextField(text_field); /* return via XtMalloc */
DtComboBoxDeleteAllItems(m_urlComboBox);
if (text) {
fe_SetTextField(text_field, text);
XtFree(text);
}
}
//////////////////////////////////////////////////////////////////////////
XP_Bool
XFE_URLBar::readUserHistory()
{
@ -631,7 +691,7 @@ XFE_URLBar::readUserHistory()
fclose(fp);
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
/* For saving out the user typed in url history list to a file*/
XP_Bool
XFE_URLBar::saveUserHistory()
@ -659,7 +719,28 @@ XFE_URLBar::saveUserHistory()
fclose(fp);
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
/*static*/
XP_Bool
XFE_URLBar::eraseUserHistory()
{
// Write an empty history file
char *filename = fe_globalPrefs.user_history_file;
FILE *fp = fopen(filename,"w");
if ( !fp )
return FALSE;
fprintf (fp,
XP_GetString(XFE_URLBAR_FILE_HEADER),
fe_version);
fclose(fp);
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
void
XFE_URLBar::frob_label(XP_Bool edited_p,
XP_Bool netsite_p)

View File

@ -52,6 +52,7 @@ public:
void recordURL(URL_Struct *url); // add the url to the drop down.
void setURLString(URL_Struct *url); // set the text's value to the url.
static void clearAll();
static const char *navigateToURL; // callback invoked when the user
// selects (or types) a new url
@ -98,6 +99,7 @@ private:
XP_Bool readUserHistory();
XP_Bool saveUserHistory();
static XP_Bool eraseUserHistory();
void frob_label(XP_Bool edited_p, XP_Bool netsite_p);
@ -125,6 +127,9 @@ private:
static void frameTitleChangedCB (Widget, XtPointer, XtPointer);
void handleFrameTitleChanged (String title);
XFE_CALLBACK_DECL(_recordURL) // add the url to the drop down.
XFE_CALLBACK_DECL(_clearAll) // clear all urls from the drop down.
};
#endif /* _xfe_urlbar_h */