1 /** 2 * @file 3 * Sidebar Window data 4 * 5 * @authors 6 * Copyright (C) 2020 Richard Russon <rich@flatcap.org> 7 * 8 * @copyright 9 * This program is free software: you can redistribute it and/or modify it under 10 * the terms of the GNU General Public License as published by the Free Software 11 * Foundation, either version 2 of the License, or (at your option) any later 12 * version. 13 * 14 * This program is distributed in the hope that it will be useful, but WITHOUT 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 * details. 18 * 19 * You should have received a copy of the GNU General Public License along with 20 * this program. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 /** 24 * @page sidebar_wdata Sidebar Window data 25 * 26 * Sidebar Window data 27 */ 28 29 #include "config.h" 30 #include <stddef.h> 31 #include "private.h" 32 #include "mutt/lib.h" 33 #include "gui/lib.h" 34 35 struct IndexSharedData; 36 37 /** 38 * sb_wdata_new - Create new Window data for the Sidebar 39 * @retval ptr New Window data 40 */ sb_wdata_new(struct IndexSharedData * shared)41struct SidebarWindowData *sb_wdata_new(struct IndexSharedData *shared) 42 { 43 struct SidebarWindowData *wdata = mutt_mem_calloc(1, sizeof(struct SidebarWindowData)); 44 wdata->shared = shared; 45 ARRAY_INIT(&wdata->entries); 46 return wdata; 47 } 48 49 /** 50 * sb_wdata_free - Free Sidebar Window data - Implements MuttWindow::wdata_free() - @ingroup window_wdata_free 51 */ sb_wdata_free(struct MuttWindow * win,void ** ptr)52void sb_wdata_free(struct MuttWindow *win, void **ptr) 53 { 54 struct SidebarWindowData *wdata = *ptr; 55 56 struct SbEntry **sbep = NULL; 57 ARRAY_FOREACH(sbep, &wdata->entries) 58 { 59 FREE(sbep); 60 } 61 ARRAY_FREE(&wdata->entries); 62 63 FREE(ptr); 64 } 65 66 /** 67 * sb_wdata_get - Get the Sidebar data for this window 68 * @param win Window 69 */ sb_wdata_get(struct MuttWindow * win)70struct SidebarWindowData *sb_wdata_get(struct MuttWindow *win) 71 { 72 if (!win || (win->type != WT_SIDEBAR)) 73 return NULL; 74 75 return win->wdata; 76 } 77