зеркало из https://github.com/mozilla/pjs.git
Move fe_DestroyWidgetTree() to XfeWidgets/MenuUtils.c as
XfeDestroyMenuWidgetTree(). Make it safe for killing private components.
This commit is contained in:
Родитель
34225ee217
Коммит
f7cb668143
|
@ -1,98 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* */
|
||||
/* hot.c --- bookmarks dialogs
|
||||
Created: Terry Weissman <terry@netscape.com>, 20-Jul-95.
|
||||
*/
|
||||
|
||||
|
||||
#include "mozilla.h"
|
||||
#include "xfe.h"
|
||||
#include "bkmks.h"
|
||||
|
||||
extern MWContext *fe_getBookmarkContext();
|
||||
|
||||
Boolean
|
||||
fe_SaveBookmarks (void)
|
||||
{
|
||||
if (fe_getBookmarkContext())
|
||||
if (BM_SaveBookmarks(fe_getBookmarkContext(), NULL) < 0)
|
||||
return False;
|
||||
return True;
|
||||
}
|
||||
|
||||
void
|
||||
fe_AddToBookmark (MWContext *context, const char *title, URL_Struct *url,
|
||||
time_t time)
|
||||
{
|
||||
BM_Entry *bm;
|
||||
const char *new_title;
|
||||
MWContext *bmcontext = NULL;
|
||||
|
||||
|
||||
if (!title || !*title) new_title = url->address;
|
||||
else new_title = title;
|
||||
bm = (BM_Entry*) BM_NewUrl(new_title, url->address, NULL, time);
|
||||
|
||||
bmcontext = fe_getBookmarkContext();
|
||||
BM_AppendToHeader (bmcontext, BM_GetAddHeader(bmcontext), bm);
|
||||
}
|
||||
|
||||
void
|
||||
fe_AddBookmarkCallback (Widget widget, XtPointer closure, XtPointer call_data)
|
||||
{
|
||||
MWContext *context = (MWContext *) closure;
|
||||
History_entry *h = SHIST_GetCurrent (&context->hist);
|
||||
BM_Entry *bm;
|
||||
MWContext *bmcontext = NULL;
|
||||
char *new_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);
|
||||
|
||||
fe_UserActivity (context);
|
||||
|
||||
bmcontext = fe_getBookmarkContext();
|
||||
BM_AppendToHeader (bmcontext, BM_GetAddHeader(bmcontext), bm);
|
||||
}
|
||||
|
||||
void
|
||||
fe_DestroyWidgetTree(Widget *widgets, int n)
|
||||
{
|
||||
int i;
|
||||
Widget *morekids = NULL;
|
||||
int nmorekids = 0;
|
||||
Widget submenu = 0;
|
||||
|
||||
if (n <= 0) return;
|
||||
|
||||
for (i = n-1; i >= 0; i--) {
|
||||
XtVaGetValues (widgets[i], XmNsubMenuId, &submenu, 0);
|
||||
if (submenu) {
|
||||
XtVaGetValues (widgets[i], XmNchildren, &morekids,
|
||||
XmNnumChildren, &nmorekids, 0);
|
||||
if(nmorekids > 0) {
|
||||
fe_DestroyWidgetTree (morekids, nmorekids);
|
||||
}
|
||||
}
|
||||
XtDestroyWidget (widgets[i]);
|
||||
}
|
||||
}
|
|
@ -26,6 +26,8 @@
|
|||
#include "MsgView.h"
|
||||
#include "felocale.h"
|
||||
|
||||
#include <Xfe/MenuUtil.h> // for XfeDestroyMenuWidgetTree()
|
||||
|
||||
XFE_AttachmentMenu::XFE_AttachmentMenu(Widget w, XFE_Frame *frame)
|
||||
{
|
||||
m_cascade = w;
|
||||
|
@ -140,7 +142,7 @@ XFE_AttachmentMenu::update()
|
|||
nkids -= m_firstslot;
|
||||
|
||||
XtUnmanageChildren (kids, nkids);
|
||||
fe_DestroyWidgetTree(kids, nkids);
|
||||
XfeDestroyMenuWidgetTree(kids,nkids,False);
|
||||
}
|
||||
|
||||
add_attachment_menu_items(m_submenu);
|
||||
|
|
|
@ -178,7 +178,7 @@ XFE_BookmarkMenu::reallyUpdateRoot()
|
|||
{
|
||||
XtUnmanageChildren(children,numChildren);
|
||||
|
||||
fe_DestroyWidgetTree(children,numChildren);
|
||||
XfeDestroyMenuWidgetTree(children,numChildren,False);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ XFE_EditRecentMenu::destroyItems()
|
|||
if (nkids) {
|
||||
XtUnmanageChildren (kids, nkids);
|
||||
|
||||
fe_DestroyWidgetTree(kids, nkids);
|
||||
XfeDestroyMenuWidgetTree(kids,nkids,False);
|
||||
#ifdef DEBUG_rhess2
|
||||
fprintf(stderr, "destroyItems::[ %d ]\n", nkids);
|
||||
#endif
|
||||
|
|
|
@ -275,7 +275,7 @@ XFE_FolderMenu::update()
|
|||
nkids -= m_firstslot;
|
||||
|
||||
XtUnmanageChildren (kids, nkids);
|
||||
fe_DestroyWidgetTree(kids, nkids);
|
||||
XfeDestroyMenuWidgetTree(kids, nkids,False);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -27,9 +27,12 @@
|
|||
#include "felocale.h"
|
||||
#include "intl_csi.h"
|
||||
|
||||
#include <Xfe/MenuUtil.h> // for XfeDestroyMenuWidgetTree()
|
||||
|
||||
#include "xpgetstr.h" // for XP_GetString()
|
||||
extern int XFE_UNTITLED;
|
||||
|
||||
|
||||
#define MAX_ITEM_WIDTH 40
|
||||
|
||||
typedef struct HistoryCons {
|
||||
|
@ -186,7 +189,7 @@ XFE_HistoryMenu::update()
|
|||
{
|
||||
XtUnmanageChildren (kids, nkids);
|
||||
|
||||
fe_DestroyWidgetTree(kids, nkids);
|
||||
XfeDestroyMenuWidgetTree(kids, nkids,False);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -574,7 +574,6 @@ extern int fe_RemoteCommands (Display *dpy, Window window, char **commands);
|
|||
extern XtActionsRec fe_CommandActions [], fe_MailNewsActions [];
|
||||
extern int fe_CommandActionsSize, fe_MailNewsActionsSize;
|
||||
extern void fe_UnmanageChild_safe (Widget w);
|
||||
extern void fe_DestroyWidgetTree(Widget *kids, int nkids);
|
||||
|
||||
/*
|
||||
* Context protection/destruction releated routines
|
||||
|
|
Загрузка…
Ссылка в новой задаче