Replace old-style bookmarks with RDF and clean up the openFileAction

This commit is contained in:
slamm%netscape.com 1998-08-26 18:34:34 +00:00
Родитель 54e3eb7019
Коммит 9465caab4a
2 изменённых файлов: 53 добавлений и 70 удалений

Просмотреть файл

@ -40,7 +40,10 @@
#include "BookmarkMenu.h" // Need for file bookmark generate function #include "BookmarkMenu.h" // Need for file bookmark generate function
#endif #endif
#ifdef OLD_BOOKMARKS
#include "bkmks.h" #include "bkmks.h"
#endif /*OLD_BOOKMARKS*/
#include "htrdf.h"
#include "net.h" #include "net.h"
#include "layers.h" #include "layers.h"
#include "ntypes.h" #include "ntypes.h"
@ -68,6 +71,7 @@
extern int XFE_ERROR_SAVING_OPTIONS; extern int XFE_ERROR_SAVING_OPTIONS;
extern int XFE_COMMANDS_OPEN_FILE_USAGE; extern int XFE_COMMANDS_OPEN_FILE_USAGE;
extern int XFE_COMMANDS_ADD_BOOKMARK_USAGE;
#ifdef EDITOR #ifdef EDITOR
extern int XFE_EDITOR_ALERT_ABOUT_DOCUMENT; extern int XFE_EDITOR_ALERT_ABOUT_DOCUMENT;
extern int XFE_EDITOR_ALERT_FRAME_DOCUMENT; extern int XFE_EDITOR_ALERT_FRAME_DOCUMENT;
@ -523,7 +527,9 @@ XFE_HTMLView::doCommand(CommandType cmd, void *callData, XFE_CommandInfo* info)
} }
else if (IS_CMD(xfeCmdOpenPageChooseFile)) else if (IS_CMD(xfeCmdOpenPageChooseFile))
{ {
openFileAction(info->params, info->nparams); XP_ASSERT(info);
openFileAction(info->params, *info->nparams);
getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating); getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating);
return; return;
@ -763,18 +769,30 @@ XFE_HTMLView::doCommand(CommandType cmd, void *callData, XFE_CommandInfo* info)
HG28732 HG28732
else if (IS_CMD(xfeCmdAddBookmark)) else if (IS_CMD(xfeCmdAddBookmark))
{ {
History_entry *h = SHIST_GetCurrent (&m_contextData->hist); XP_ASSERT(info);
BM_Entry *bm;
char *new_title;
if (!h) return; Cardinal ac = *info->nparams;
String *av = info->params;
if (!h->title || !*h->title) new_title = h->address; if (ac == 1 && av[0])
else new_title = h->title; {
bm = (BM_Entry*)BM_NewUrl( new_title, h->address, NULL, h->last_access); HT_AddBookmark (av[0], NULL);
}
BM_AppendToHeader (XFE_BookmarkFrame::main_bm_context, else if (ac == 2 && av[0] && av[1])
BM_GetAddHeader(XFE_BookmarkFrame::main_bm_context), bm); {
HT_AddBookmark (av[0], av[1]);
}
else if (ac > 2)
{
fprintf (stderr, XP_GetString(XFE_COMMANDS_ADD_BOOKMARK_USAGE),
fe_progname);
}
else
{
History_entry *h = SHIST_GetCurrent (&m_contextData->hist);
if (h)
HT_AddBookmark (h->address, h->title);
}
return; return;
} }
else if (IS_CMD(xfeCmdAddFrameBookmark)) else if (IS_CMD(xfeCmdAddFrameBookmark))
@ -787,35 +805,16 @@ XFE_HTMLView::doCommand(CommandType cmd, void *callData, XFE_CommandInfo* info)
History_entry *h = SHIST_GetCurrent (&context->hist); History_entry *h = SHIST_GetCurrent (&context->hist);
if (!h) return; if (h)
HT_AddBookmark (h->address, h->title);
BM_Entry *bm;
char *new_title;
if (!h->title || !*h->title) new_title = h->address;
else new_title = h->title;
bm = (BM_Entry*)BM_NewUrl( new_title, h->address, NULL, h->last_access);
BM_AppendToHeader (XFE_BookmarkFrame::main_bm_context,
BM_GetAddHeader(XFE_BookmarkFrame::main_bm_context), bm);
return; return;
} }
else if (IS_CMD(xfeCmdAddLinkBookmark)) else if (IS_CMD(xfeCmdAddLinkBookmark))
{ {
if (!m_urlUnderMouse) return; if (m_urlUnderMouse)
HT_AddBookmark (m_urlUnderMouse->address, NULL);
BM_Entry *bm;
char *new_title;
new_title = m_urlUnderMouse->address; /* Maybe we can do something
smart someday. -slamm */
bm = (BM_Entry*)BM_NewUrl( new_title, m_urlUnderMouse->address,
NULL, 0);
BM_AppendToHeader (XFE_BookmarkFrame::main_bm_context,
BM_GetAddHeader(XFE_BookmarkFrame::main_bm_context), bm);
return; return;
} }
else if (IS_CMD(xfeCmdPrint)) else if (IS_CMD(xfeCmdPrint))
@ -2485,42 +2484,29 @@ fe_openTargetUrl(MWContext * context,LO_AnchorData * anchor_data)
} }
void void
XFE_HTMLView::openFileAction (String *av, Cardinal *ac) XFE_HTMLView::openFileAction (String *av, Cardinal ac)
{ {
MWContext *context = m_contextData; MWContext *context = m_contextData;
MWContext *old_context = NULL; Boolean useNewWindow = False;
/* See also fe_open_url_action() */ if (ac > 1 && av[ac-1] )
Boolean other_p = False;
fe_UserActivity (context);
if (*ac && av[*ac-1] && !strcmp (av[*ac-1], "<remote>"))
(*ac)--;
if (*ac > 1 && av[*ac-1] )
{ {
if ((!strcasecomp (av[*ac-1], "new-window") || // Search context list for the parameter string
!strcasecomp (av[*ac-1], "new_window") || // If there is a match, use that context.
!strcasecomp (av[*ac-1], "newWindow") || // Otherwise, the param was probably a "new_window" param.
!strcasecomp (av[*ac-1], "new"))) // If not "new_window", too bad, give a new window anyway.
{
other_p = True; MWContext *named_context = XP_FindNamedContextInList(context, av[ac-1]);
(*ac)--;
} if (named_context)
else if ((old_context = XP_FindNamedContextInList(context, av[*ac-1]))) context = named_context;
{
context = old_context;
other_p = False;
(*ac)--;
}
else else
{ useNewWindow = True;
other_p = True;
(*ac)--; ac--;
}
} }
if (*ac == 1 && av[0]) if (ac == 1 && av[0])
{ {
#ifndef PATH_MAX #ifndef PATH_MAX
#define PATH_MAX 1024 #define PATH_MAX 1024
@ -2540,11 +2526,8 @@ XFE_HTMLView::openFileAction (String *av, Cardinal *ac)
PR_snprintf (newURL, sizeof (newURL), "file:%s/%.900s", PR_snprintf (newURL, sizeof (newURL), "file:%s/%.900s",
cwd_buf, av[0]); cwd_buf, av[0]);
} }
#ifdef DEBUG_slamm
fprintf(stderr,"%s",newURL);
#endif
url_struct = NET_CreateURLStruct (newURL, NET_DONT_RELOAD); url_struct = NET_CreateURLStruct (newURL, NET_DONT_RELOAD);
if (other_p) if (useNewWindow)
{ {
fe_MakeWindow (XtParent (CONTEXT_WIDGET (context)), fe_MakeWindow (XtParent (CONTEXT_WIDGET (context)),
context, url_struct, NULL, context, url_struct, NULL,
@ -2553,7 +2536,7 @@ XFE_HTMLView::openFileAction (String *av, Cardinal *ac)
else else
fe_GetURL (context, url_struct, FALSE); fe_GetURL (context, url_struct, FALSE);
} }
else if (*ac > 1) else if (ac > 1)
{ {
fprintf (stderr, fprintf (stderr,
XP_GetString(XFE_COMMANDS_OPEN_FILE_USAGE), XP_GetString(XFE_COMMANDS_OPEN_FILE_USAGE),

Просмотреть файл

@ -136,7 +136,7 @@ private:
void makeScroller(Widget parent); void makeScroller(Widget parent);
void findLayerForPopupMenu(Widget widget, XEvent *event); void findLayerForPopupMenu(Widget widget, XEvent *event);
void reload(Widget, XEvent *event, XP_Bool onlyReloadFrame = FALSE); void reload(Widget, XEvent *event, XP_Bool onlyReloadFrame = FALSE);
void openFileAction (String *av, Cardinal *ac); void openFileAction (String *av, Cardinal ac);
// This gets called by our toplevel when the encoding has // This gets called by our toplevel when the encoding has
// changed for this window. // changed for this window.