Changeset 61784ed in mainline for uspace/app/nav/panel.c
- Timestamp:
- 2021-10-25T00:32:45Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0e80e40
- Parents:
- b36ebb42
- git-author:
- Jiri Svoboda <jiri@…> (2021-10-05 17:07:26)
- git-committer:
- jxsvoboda <5887334+jxsvoboda@…> (2021-10-25 00:32:45)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nav/panel.c
rb36ebb42 r61784ed 38 38 #include <gfx/render.h> 39 39 #include <stdlib.h> 40 #include <str.h> 40 41 #include <ui/control.h> 41 42 #include <ui/paint.h> … … 81 82 82 83 panel->window = window; 84 list_initialize(&panel->entries); 83 85 *rpanel = panel; 84 86 return EOK; … … 95 97 void panel_destroy(panel_t *panel) 96 98 { 99 panel_entry_t *entry; 100 101 entry = panel_first(panel); 102 while (entry != NULL) { 103 panel_entry_delete(entry); 104 entry = panel_first(panel); 105 } 106 97 107 ui_control_delete(panel->control); 98 108 free(panel); … … 196 206 } 197 207 208 /** Append new panel entry. 209 * 210 * @param panel Panel 211 * @param name File name 212 * @param size File size; 213 * @return EOK on success or an error code 214 */ 215 errno_t panel_entry_append(panel_t *panel, const char *name, uint64_t size) 216 { 217 panel_entry_t *entry; 218 219 entry = calloc(1, sizeof(panel_entry_t)); 220 if (entry == NULL) 221 return ENOMEM; 222 223 entry->panel = panel; 224 entry->name = str_dup(name); 225 if (entry->name == NULL) { 226 free(entry); 227 return ENOMEM; 228 } 229 230 entry->size = size; 231 link_initialize(&entry->lentries); 232 list_append(&entry->lentries, &panel->entries); 233 return EOK; 234 } 235 236 /** Delete panel entry. 237 * 238 * @param entry Panel entry 239 */ 240 void panel_entry_delete(panel_entry_t *entry) 241 { 242 list_remove(&entry->lentries); 243 free(entry->name); 244 free(entry); 245 } 246 247 /** Return first panel entry. 248 * 249 * @panel Panel 250 * @return First panel entry or @c NULL if there are no entries 251 */ 252 panel_entry_t *panel_first(panel_t *panel) 253 { 254 link_t *link; 255 256 link = list_first(&panel->entries); 257 if (link == NULL) 258 return NULL; 259 260 return list_get_instance(link, panel_entry_t, lentries); 261 } 262 263 /** Return next panel entry. 264 * 265 * @param cur Current entry 266 * @return Next entry or @c NULL if @a cur is the last entry 267 */ 268 panel_entry_t *panel_next(panel_entry_t *cur) 269 { 270 link_t *link; 271 272 link = list_next(&cur->lentries, &cur->panel->entries); 273 if (link == NULL) 274 return NULL; 275 276 return list_get_instance(link, panel_entry_t, lentries); 277 } 198 278 199 279 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.