зеркало из https://github.com/mozilla/pjs.git
Replace old-style bookmarks with RDF and clean up the openFileAction
This commit is contained in:
Родитель
54e3eb7019
Коммит
9465caab4a
|
@ -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;
|
||||||
|
@ -762,19 +768,31 @@ XFE_HTMLView::doCommand(CommandType cmd, void *callData, XFE_CommandInfo* info)
|
||||||
}
|
}
|
||||||
HG28732
|
HG28732
|
||||||
else if (IS_CMD(xfeCmdAddBookmark))
|
else if (IS_CMD(xfeCmdAddBookmark))
|
||||||
|
{
|
||||||
|
XP_ASSERT(info);
|
||||||
|
|
||||||
|
Cardinal ac = *info->nparams;
|
||||||
|
String *av = info->params;
|
||||||
|
|
||||||
|
if (ac == 1 && av[0])
|
||||||
|
{
|
||||||
|
HT_AddBookmark (av[0], NULL);
|
||||||
|
}
|
||||||
|
else if (ac == 2 && av[0] && av[1])
|
||||||
|
{
|
||||||
|
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);
|
History_entry *h = SHIST_GetCurrent (&m_contextData->hist);
|
||||||
BM_Entry *bm;
|
if (h)
|
||||||
char *new_title;
|
HT_AddBookmark (h->address, h->title);
|
||||||
|
}
|
||||||
if (!h) return;
|
|
||||||
|
|
||||||
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(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;
|
{
|
||||||
|
// Search context list for the parameter string
|
||||||
|
// If there is a match, use that context.
|
||||||
|
// Otherwise, the param was probably a "new_window" param.
|
||||||
|
// If not "new_window", too bad, give a new window anyway.
|
||||||
|
|
||||||
fe_UserActivity (context);
|
MWContext *named_context = XP_FindNamedContextInList(context, av[ac-1]);
|
||||||
if (*ac && av[*ac-1] && !strcmp (av[*ac-1], "<remote>"))
|
|
||||||
(*ac)--;
|
|
||||||
|
|
||||||
if (*ac > 1 && av[*ac-1] )
|
if (named_context)
|
||||||
{
|
context = named_context;
|
||||||
if ((!strcasecomp (av[*ac-1], "new-window") ||
|
|
||||||
!strcasecomp (av[*ac-1], "new_window") ||
|
|
||||||
!strcasecomp (av[*ac-1], "newWindow") ||
|
|
||||||
!strcasecomp (av[*ac-1], "new")))
|
|
||||||
{
|
|
||||||
other_p = True;
|
|
||||||
(*ac)--;
|
|
||||||
}
|
|
||||||
else if ((old_context = XP_FindNamedContextInList(context, av[*ac-1])))
|
|
||||||
{
|
|
||||||
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.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче