Added support for Smart Browsing

This commit is contained in:
mcafee%netscape.com 1998-09-21 05:27:50 +00:00
parent ba54d9a1b4
commit 2b0a693f1c
5 changed files with 195 additions and 94 deletions

View File

@ -5401,6 +5401,23 @@ Sometimes a document will provide its own colors and background
*prefsLang*langList.visibleItemCount: 15
*prefsLang*otherLabel.labelString: Others:
! Preferences dialog - Smart Browsing
*prefs*relatedFrame*relatedBoxLabel.labelString: What's Related
*prefs*relatedFrame*enableRelated.labelString: Enable What's Related
*prefs*relatedFrame*autoloadLabel.labelString: Automatically Load What's Related
*prefs*relatedFrame*autoloadAlways.labelString: Always
*prefs*relatedFrame*autoloadAdaptive.labelString: After First Use
*prefs*relatedFrame*autoloadNever.labelString: Never
*prefs*relatedFrame*excludedLabel.labelString: \
Do not request "What's Related" information for\n\
the following domains: (a comma separated list)
*prefs*keywordFrame*keywordBoxLabel.labelString: Internet Keywords
*prefs*keywordFrame*enableKeywords.labelString: Enable Internet Keywords
! Preferences dialog - Advanced
*prefs*advanced*showImage.labelString: \
@ -5977,6 +5994,7 @@ for download.
*pref.colors: Colors
*pref.browser: Navigator
*pref.lang: Languages
*pref.smart: Smart Browsing
*pref.applications: Applications
*pref.privacy: Privacy
*pref.mailNews: Mail & Groups
@ -6007,6 +6025,7 @@ for download.
*prefDesc.colors: Change the colors in your display
*prefDesc.browser: Specify the home page location
*prefDesc.lang: View web pages in different languages
*prefDesc.smart: Configure browsing aids
*prefDesc.applications: Specify helper applications for different file types
*prefDesc.privacy: Establish your level of privacy protection
*prefDesc.mailNews: Change appearance settings for Mail & Groups

View File

@ -123,6 +123,7 @@ CPPSRCS = \
PrefsDialogBrowser.cpp \
PrefsDialogGeneral.cpp \
PrefsDialogMailnews.cpp \
PrefsDialogSmart.cpp \
PrefsLang.cpp \
PrefsProxiesView.cpp \
RDFBase.cpp \

View File

@ -36,7 +36,6 @@ struct PrefsDataGeneralAppearance
Widget page;
// Launch
Widget navigator_toggle;
Widget messenger_toggle;
Widget collabra_toggle;
@ -46,7 +45,6 @@ struct PrefsDataGeneralAppearance
Widget calendar_toggle;
// Show Toolbar as
Widget pic_and_text_toggle;
Widget pic_only_toggle;
Widget text_only_toggle;
@ -60,7 +58,6 @@ struct PrefsDataGeneralFonts
Widget page;
// Font
Widget encoding_label;
Widget proportional_label;
Widget fixed_label;
@ -91,7 +88,6 @@ struct PrefsDataGeneralColors
Widget page;
// Colors
Widget text_color_button;
Widget bg_color_button;
Widget links_color_button;
@ -102,7 +98,6 @@ struct PrefsDataGeneralColors
};
// ---------- Advanced ----------
struct PrefsDataGeneralAdvanced
{
MWContext *context;
@ -205,7 +200,6 @@ struct PrefsDataHelpFiles
#endif /* PREFS_UNSUPPORTED */
// ---------- Browser ----------
struct PrefsDataBrowser
{
MWContext *context;
@ -255,8 +249,33 @@ struct PrefsDataBrowserLang
int pref_lang_count;
};
// ---------- Mail News ----------
// ---------- Smart ----------
struct PrefsDataBrowserSmart
{
MWContext *context;
Widget prompt_dialog;
Widget page;
// Related links
Widget rl_enabled_toggle;
// Related links autoload
Widget rl_autoload_label;
Widget rl_autoload_radio_always;
Widget rl_autoload_radio_adaptive;
Widget rl_autoload_radio_never;
// Related links excluded domains
Widget rl_excluded_label;
Widget rl_excluded_text;
// Internet Keywords
Widget enable_internet_keywords;
};
// ---------- Mail News ----------
struct PrefsDataMailNews
{
MWContext *context;
@ -322,7 +341,6 @@ struct PrefsDataApplEdit
};
// ---------- Editor ----------
struct PrefsDataEditor
{
MWContext *context;
@ -369,7 +387,6 @@ struct PrefsDataEditorPublish
#ifdef PREFS_UNSUPPORTED
// ---------- Offline ----------
struct PrefsDataOffline
{
MWContext *context;

View File

@ -74,6 +74,7 @@ static char *TAG_BOLD = "BOLD";
#define CAT_APPS "Applications"
#define CAT_PRIVACY "Privacy"
#define CAT_LANG "Languages"
#define CAT_SMART "Smart Browsing"
#define CAT_CACHE "Cache"
#define CAT_PROXIES "Proxies"
#define CAT_MAILNEWS_IDENTITY "Identity"
@ -102,6 +103,7 @@ static char *TAG_BOLD = "BOLD";
#define CAT_RESNAME_COLORS "pref.colors"
#define CAT_RESNAME_BROWSER "pref.browser"
#define CAT_RESNAME_LANG "pref.lang"
#define CAT_RESNAME_SMART "pref.smart"
#define CAT_RESNAME_APPS "pref.applications"
#define CAT_RESNAME_PRIVACY "pref.privacy"
#define CAT_RESNAME_MAILNEWS "pref.mailNews"
@ -136,6 +138,7 @@ static char *TAG_BOLD = "BOLD";
#define CAT_RESCLASS_COLORS "Pref.Colors"
#define CAT_RESCLASS_BROWSER "Pref.Browser"
#define CAT_RESCLASS_LANG "Pref.Lang"
#define CAT_RESCLASS_SMART "Pref.Smart"
#define CAT_RESCLASS_APPS "Pref.Applications"
#define CAT_RESCLASS_PRIVACY "Pref.Privacy"
#define CAT_RESCLASS_MAILNEWS "Pref.MailNews"
@ -170,6 +173,7 @@ static char *TAG_BOLD = "BOLD";
#define DESC_RESNAME_COLORS "prefDesc.colors"
#define DESC_RESNAME_BROWSER "prefDesc.browser"
#define DESC_RESNAME_LANG "prefDesc.lang"
#define DESC_RESNAME_SMART "prefDesc.smart"
#define DESC_RESNAME_APPS "prefDesc.applications"
#define DESC_RESNAME_PRIVACY "prefDesc.privacy"
#define DESC_RESNAME_MAILNEWS "prefDesc.mailNews"
@ -204,6 +208,7 @@ static char *TAG_BOLD = "BOLD";
#define DESC_RESCLASS_COLORS "PrefDesc.Colors"
#define DESC_RESCLASS_BROWSER "PrefDesc.Browser"
#define DESC_RESCLASS_LANG "PrefDesc.Lang"
#define DESC_RESCLASS_SMART "PrefDesc.Smart"
#define DESC_RESCLASS_APPS "PrefDesc.Applications"
#define DESC_RESCLASS_PRIVACY "PrefDesc.Privacy"
#define DESC_RESCLASS_MAILNEWS "PrefDesc.MailNews"
@ -239,6 +244,7 @@ typedef enum _prefsPageType {
PAGE_TYPE_COLORS,
PAGE_TYPE_BROWSER,
PAGE_TYPE_LANG,
PAGE_TYPE_SMART,
PAGE_TYPE_APPS,
PAGE_TYPE_PRIVACY,
PAGE_TYPE_MAILNEWS,
@ -475,6 +481,17 @@ struct _prefsCategory prefsBrowser[] = {
0,
PAGE_TYPE_APPS,
},
{
CAT_SMART,
CAT_RESNAME_SMART,
CAT_RESCLASS_SMART,
DESC_RESNAME_SMART,
DESC_RESCLASS_SMART,
TRUE,
NULL,
0,
PAGE_TYPE_SMART,
},
{
CAT_PRIVACY,
CAT_RESNAME_PRIVACY,
@ -987,7 +1004,8 @@ void XFE_PrefsPage::map()
// Initialize the page
if (doInitInMap()){
if (! isInitialized()) init();
if (! isInitialized())
read();
setChanged(TRUE);
}
@ -1433,7 +1451,7 @@ void XFE_PrefsDialog::saveChanges()
for (int i = 0; i < m_numPages; i++) {
if (m_pages[i]->isChanged()) {
m_pages[i]->save();
m_pages[i]->write();
}
}
@ -1827,6 +1845,9 @@ void XFE_PrefsDialog::newPage(XFE_PrefsPage *&page,
case PAGE_TYPE_APPS:
page = new XFE_PrefsPageGeneralAppl(this);
break;
case PAGE_TYPE_SMART:
page = new XFE_PrefsPageBrowserSmart(this);
break;
case PAGE_TYPE_PRIVACY:
page = new XFE_PrefsPageGeneralPrivacy(this);
break;

View File

@ -27,7 +27,6 @@
#include "xfe.h"
#include "prefapi.h"
#include "PrefsDialog.h"
#include "prefapi.h"
#include <Xm/LabelG.h>
#include <Xm/ToggleBG.h>
@ -39,11 +38,24 @@
// Smart Browsing preferences
//
#define PREF_BROWSER_RELATED_ENABLED "browser.related.enabled"
#define PREF_BROWSER_RELATED_AUTOLOAD "browser.related.autoload"
#define PREF_BROWSER_RELATED_DISABLEDFORDOMAINS "browser.related.disabledForDomains"
#define PREF_BROWSER_GOBROWSING_ENABLED "browser.goBrowsing.enabled"
/* related links autoload */
#define RELATED_LINKS_AUTOLOAD_ALWAYS 0
#define RELATED_LINKS_AUTOLOAD_ADAPTIVE 1
#define RELATED_LINKS_AUTOLOAD_NEVER 2
//////////////////////////////////////////////////////////////////////////
XFE_PrefsPageBrowserSmart::XFE_PrefsPageBrowserSmart(XFE_PrefsDialog *dialog)
: XFE_PrefsPage(dialog),
m_prefsDataBrowserSmart(0)
{
m_rl_need_chrome_update = FALSE;
}
//////////////////////////////////////////////////////////////////////////
@ -303,31 +315,72 @@ XFE_PrefsPageBrowserSmart::create()
cb_toggleRelatedAutoload,
(XtPointer) fep);
// Add callbacks to internet keyword toggle button
// Add callbacks to internet keyword toggle button
// XtAddCallback(fep->enable_internet_keywords, XmNvalueChangedCallback,
// cb_toggleInternetKeywords, fep);
setCreated(TRUE);
}
//////////////////////////////////////////////////////////////////////////
// Pull the prefs out of the backend and display them.
void
XFE_PrefsPageBrowserSmart::init()
XFE_PrefsPageBrowserSmart::read()
{
XP_ASSERT( m_prefsDataBrowserSmart != NULL );
PrefsDataBrowserSmart * fep = m_prefsDataBrowserSmart;
XP_Bool backendBoolValue;
char *backendCharValue;
int backendIntValue;
int prefStatus;
// Related links enabled
PREF_GetBoolPref(PREF_BROWSER_RELATED_ENABLED, &backendBoolValue);
XtVaSetValues(fep->rl_enabled_toggle,
XmNset, fe_globalPrefs.related_links_enabled,
XmNsensitive, !PREF_PrefIsLocked("browser.related.enabled"),
XmNset, backendBoolValue,
XmNsensitive, !PREF_PrefIsLocked(PREF_BROWSER_RELATED_ENABLED),
NULL);
// Excluded domaings
XmTextSetString(fep->rl_excluded_text,
fe_globalPrefs.related_disabled_domains);
// Autoload
prefStatus = PREF_GetIntPref(PREF_BROWSER_RELATED_AUTOLOAD,
&backendIntValue);
// Unset everybody
XmToggleButtonGadgetSetState(fep->rl_autoload_radio_never, False, False);
XmToggleButtonGadgetSetState(fep->rl_autoload_radio_adaptive, False, False);
XmToggleButtonGadgetSetState(fep->rl_autoload_radio_always, False, False);
// Set the right one.
switch(backendIntValue) {
case RELATED_LINKS_AUTOLOAD_NEVER:
XmToggleButtonGadgetSetState(fep->rl_autoload_radio_never, True, False);
break;
case RELATED_LINKS_AUTOLOAD_ADAPTIVE:
XmToggleButtonGadgetSetState(fep->rl_autoload_radio_adaptive, True, False);
break;
case RELATED_LINKS_AUTOLOAD_ALWAYS:
XmToggleButtonGadgetSetState(fep->rl_autoload_radio_always, True, False);
break;
default:
XP_ASSERT(0);
break;
}
updateRelatedAutoloadSensitive();
// Excluded domaings
fe_PrefReadString(PREF_BROWSER_RELATED_DISABLEDFORDOMAINS, &backendCharValue);
XmTextSetString(fep->rl_excluded_text, backendCharValue);
// Related links enabled
PREF_GetBoolPref(PREF_BROWSER_GOBROWSING_ENABLED, &backendBoolValue);
XtVaSetValues(fep->enable_internet_keywords,
XmNset, backendBoolValue,
XmNsensitive, !PREF_PrefIsLocked(PREF_BROWSER_GOBROWSING_ENABLED),
NULL);
updateRelatedLinksSensitive();
updateInternetKeywordsSensitive();
@ -345,56 +398,50 @@ XFE_PrefsPageBrowserSmart::install()
}
}
//////////////////////////////////////////////////////////////////////////
// Write UI values to PREF backend.
void
XFE_PrefsPageBrowserSmart::save()
XFE_PrefsPageBrowserSmart::write()
{
PrefsDataBrowserSmart * fep = m_prefsDataBrowserSmart;
XP_Bool old_related_links_enabled;
XP_Bool currentValue;
XP_ASSERT(fep);
// Related links
XP_Bool old_related_links_enabled = fe_globalPrefs.related_links_enabled;
// Related links enabled
fe_globalPrefs.related_links_enabled =
XfeToggleButtonIsSet(fep->rl_enabled_toggle);
PREF_GetBoolPref(PREF_BROWSER_RELATED_ENABLED, &old_related_links_enabled);
currentValue = XfeToggleButtonIsSet(fep->rl_enabled_toggle);
PREF_SetBoolPref("browser.related.enabled",
currentValue);
// If something changed, we need to update senitivity.
if(old_related_links_enabled != currentValue) {
m_rl_need_chrome_update = TRUE;
}
// Related links autoload
if (old_related_links_enabled != fe_globalPrefs.related_links_enabled)
{
m_rl_need_chrome_update = TRUE;
}
// Related links autoload
if (XfeToggleButtonIsSet(fep->rl_autoload_radio_always))
{
fe_globalPrefs.related_links_autoload = RELATED_LINKS_AUTOLOAD_ALWAYS;
}
if (XfeToggleButtonIsSet(fep->rl_autoload_radio_adaptive))
{
fe_globalPrefs.related_links_autoload = RELATED_LINKS_AUTOLOAD_ADAPTIVE;
}
if (XfeToggleButtonIsSet(fep->rl_autoload_radio_never))
{
fe_globalPrefs.related_links_autoload = RELATED_LINKS_AUTOLOAD_NEVER;
}
if (XfeToggleButtonIsSet(fep->rl_autoload_radio_always)) {
PREF_SetIntPref(PREF_BROWSER_RELATED_AUTOLOAD, RELATED_LINKS_AUTOLOAD_ALWAYS);
} else if (XfeToggleButtonIsSet(fep->rl_autoload_radio_adaptive)) {
PREF_SetIntPref(PREF_BROWSER_RELATED_AUTOLOAD, RELATED_LINKS_AUTOLOAD_ADAPTIVE);
} else if (XfeToggleButtonIsSet(fep->rl_autoload_radio_never)) {
PREF_SetIntPref(PREF_BROWSER_RELATED_AUTOLOAD, RELATED_LINKS_AUTOLOAD_NEVER);
} else {
XP_ASSERT(0);
}
// Excluded domains
fe_globalPrefs.related_disabled_domains =
XmTextGetString(fep->rl_excluded_text);
PREF_SetCharPref(PREF_BROWSER_RELATED_DISABLEDFORDOMAINS,
XmTextGetString(fep->rl_excluded_text));
// Internet Keywords
fe_globalPrefs.internet_keywords_enabled =
XfeToggleButtonIsSet(fep->enable_internet_keywords);
// Install preferences
install();
PREF_SetBoolPref(PREF_BROWSER_GOBROWSING_ENABLED,
XfeToggleButtonIsSet(fep->enable_internet_keywords));
// Install
install();
}
//////////////////////////////////////////////////////////////////////////
PrefsDataBrowserSmart *
XFE_PrefsPageBrowserSmart::getData()
{
@ -402,15 +449,17 @@ XFE_PrefsPageBrowserSmart::getData()
}
//////////////////////////////////////////////////////////////////////////
void
XFE_PrefsPageBrowserSmart::updateRelatedAutoloadSensitive()
XFE_PrefsPageBrowserSmart::updateRelatedLinksSensitive()
{
XP_ASSERT( m_prefsDataBrowserSmart != NULL );
PrefsDataBrowserSmart * fep = m_prefsDataBrowserSmart;
XP_Bool backendBoolValue;
// Related links enabled
PREF_GetBoolPref(PREF_BROWSER_RELATED_ENABLED, &backendBoolValue);
Boolean sensitive =
!PREF_PrefIsLocked("browser.related.enabled") &&
fe_globalPrefs.related_links_enabled;
!PREF_PrefIsLocked("PREF_BROWSER_RELATED_ENABLED") && backendBoolValue;
// autoload label
XtVaSetValues(fep->rl_autoload_label,
@ -419,19 +468,16 @@ XFE_PrefsPageBrowserSmart::updateRelatedAutoloadSensitive()
// autoload always
XtVaSetValues(fep->rl_autoload_radio_always,
XmNset, (fe_globalPrefs.related_links_autoload == RELATED_LINKS_AUTOLOAD_ALWAYS),
XmNsensitive, sensitive,
NULL);
// autoload adaptive
XtVaSetValues(fep->rl_autoload_radio_adaptive,
XmNset, (fe_globalPrefs.related_links_autoload == RELATED_LINKS_AUTOLOAD_ADAPTIVE),
XmNsensitive, sensitive,
NULL);
// autoload never
XtVaSetValues(fep->rl_autoload_radio_never,
XmNset, (fe_globalPrefs.related_links_autoload == RELATED_LINKS_AUTOLOAD_NEVER),
XmNsensitive, sensitive,
NULL);
@ -458,11 +504,12 @@ XFE_PrefsPageBrowserSmart::updateInternetKeywordsSensitive()
// enable keywords
XtVaSetValues(fep->enable_internet_keywords,
XmNset, fe_globalPrefs.internet_keywords_enabled,
XmNsensitive, keywords_sensitive,
NULL);
}
//////////////////////////////////////////////////////////////////////////
void
XFE_PrefsPageBrowserSmart::cb_toggleRelatedEnabled(Widget w,
XtPointer clientData,
@ -481,11 +528,12 @@ XFE_PrefsPageBrowserSmart::cb_toggleRelatedEnabled(Widget w,
XP_ASSERT( cb != NULL );
XP_ASSERT( w == fep->rl_enabled_toggle );
fe_globalPrefs.related_links_enabled = (XP_Bool) cb->set;
obj->m_rl_need_chrome_update = True;
// Actually set the pref so that read() will read it from
// the backend properly.
PREF_SetBoolPref(PREF_BROWSER_RELATED_ENABLED, (XP_Bool)cb->set);
obj->updateRelatedAutoloadSensitive();
obj->m_rl_need_chrome_update = True;
obj->updateRelatedLinksSensitive();
}
//////////////////////////////////////////////////////////////////////////
void
@ -493,34 +541,29 @@ XFE_PrefsPageBrowserSmart::cb_toggleRelatedAutoload(Widget w,
XtPointer closure,
XtPointer callData)
{
XmToggleButtonCallbackStruct * cb =
(XmToggleButtonCallbackStruct *) callData;
PrefsDataBrowserSmart * fep = (PrefsDataBrowserSmart *) closure;
if (! cb->set)
{
XtVaSetValues(w, XmNset, True, 0);
}
else if (w == fep->rl_autoload_radio_always)
{
XtVaSetValues(fep->rl_autoload_radio_adaptive, XmNset, False, 0);
XtVaSetValues(fep->rl_autoload_radio_never, XmNset, False, 0);
}
else if (w == fep->rl_autoload_radio_adaptive)
{
XtVaSetValues(fep->rl_autoload_radio_always, XmNset, False, 0);
XtVaSetValues(fep->rl_autoload_radio_never, XmNset, False, 0);
}
else if (w == fep->rl_autoload_radio_never)
{
XtVaSetValues(fep->rl_autoload_radio_always, XmNset, False, 0);
XtVaSetValues(fep->rl_autoload_radio_adaptive, XmNset, False, 0);
}
else
{
abort();
XmToggleButtonCallbackStruct * cb =
(XmToggleButtonCallbackStruct *) callData;
PrefsDataBrowserSmart * fep = (PrefsDataBrowserSmart *) closure;
if (! cb->set) {
// We didn't get a set-toggle-button event, bail.
XtVaSetValues(w, XmNset, True, 0);
} else {
// Ok which one was it? Unset the others.
if (w == fep->rl_autoload_radio_always) {
XtVaSetValues(fep->rl_autoload_radio_adaptive, XmNset, False, 0);
XtVaSetValues(fep->rl_autoload_radio_never, XmNset, False, 0);
} else if (w == fep->rl_autoload_radio_adaptive) {
XtVaSetValues(fep->rl_autoload_radio_always, XmNset, False, 0);
XtVaSetValues(fep->rl_autoload_radio_never, XmNset, False, 0);
} else if (w == fep->rl_autoload_radio_never) {
XtVaSetValues(fep->rl_autoload_radio_always, XmNset, False, 0);
XtVaSetValues(fep->rl_autoload_radio_adaptive, XmNset, False, 0);
} else {
XP_ASSERT(0);
}
}
}
//////////////////////////////////////////////////////////////////////////