home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / hot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.6 KB  |  99 lines

  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /* */
  19. /* hot.c --- bookmarks dialogs
  20.    Created: Terry Weissman <terry@netscape.com>, 20-Jul-95.
  21.  */
  22.  
  23.  
  24. #include "mozilla.h"
  25. #include "xfe.h"
  26. #include "bkmks.h" 
  27.  
  28. extern MWContext *fe_getBookmarkContext();
  29.  
  30. Boolean
  31. fe_SaveBookmarks (void)
  32. {
  33.   if (fe_getBookmarkContext()) 
  34.     if (BM_SaveBookmarks(fe_getBookmarkContext(), NULL) < 0)
  35.       return False;
  36.   return True;
  37. }
  38.  
  39. void
  40. fe_AddToBookmark (MWContext *context, const char *title, URL_Struct *url,
  41.           time_t time)
  42. {
  43.   BM_Entry *bm;
  44.   const char *new_title;
  45.   MWContext *bmcontext = NULL;
  46.  
  47.  
  48.   if (!title || !*title) new_title = url->address;
  49.   else new_title = title;
  50.   bm = (BM_Entry*) BM_NewUrl(new_title, url->address, NULL, time);
  51.  
  52.   bmcontext = fe_getBookmarkContext();
  53.   BM_AppendToHeader (bmcontext, BM_GetAddHeader(bmcontext), bm);
  54. }
  55.  
  56. void
  57. fe_AddBookmarkCallback (Widget widget, XtPointer closure, XtPointer call_data)
  58. {
  59.   MWContext *context = (MWContext *) closure;
  60.   History_entry *h = SHIST_GetCurrent (&context->hist);
  61.   BM_Entry *bm;
  62.   MWContext *bmcontext = NULL;
  63.   char *new_title;
  64.  
  65.   if (!h) return;
  66.  
  67.   if (!h->title || !*h->title) new_title = h->address;
  68.   else new_title = h->title;
  69.   bm = (BM_Entry*)BM_NewUrl( new_title, h->address, NULL, h->last_access);
  70.  
  71.   fe_UserActivity (context);
  72.  
  73.   bmcontext = fe_getBookmarkContext();
  74.   BM_AppendToHeader (bmcontext, BM_GetAddHeader(bmcontext), bm);
  75. }
  76.  
  77. void
  78. fe_DestroyWidgetTree(Widget *widgets, int n)
  79. {
  80.     int i;
  81.     Widget *morekids = NULL;
  82.     int nmorekids = 0;
  83.     Widget submenu = 0;
  84.  
  85.     if (n <= 0) return;
  86.  
  87.     for (i = n-1; i >= 0; i--) {
  88.         XtVaGetValues (widgets[i], XmNsubMenuId, &submenu, 0);
  89.         if (submenu) {
  90.             XtVaGetValues (widgets[i], XmNchildren, &morekids,
  91.                            XmNnumChildren, &nmorekids, 0);
  92.             if(nmorekids > 0) {
  93.                 fe_DestroyWidgetTree (morekids, nmorekids);
  94.             }
  95.         }
  96.         XtDestroyWidget (widgets[i]);
  97.     }
  98. }
  99.