source: mainline/uspace/lib/ui/private/filelist.h

Last change on this file was accdf882, checked in by Jiri Svoboda <jiri@…>, 5 months ago

File / Edit (Ctrl-E) in Navigator to start editor on current file

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 * Copyright (c) 2025 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libui
30 * @{
31 */
32/**
33 * @file File list
34 */
35
36#ifndef _UI_PRIVATE_FILELIST_H
37#define _UI_PRIVATE_FILELIST_H
38
39#include <gfx/color.h>
40#include <ipc/loc.h>
41#include <ui/list.h>
42#include <ui/window.h>
43#include <stdint.h>
44#include <types/ui/filelist.h>
45
46/** File list entry */
47struct ui_file_list_entry {
48 /** Containing file list */
49 struct ui_file_list *flist;
50 /** List entry */
51 ui_list_entry_t *entry;
52 /** File name */
53 char *name;
54 /** File size */
55 uint64_t size;
56 /** @c true iff entry is a directory */
57 bool isdir;
58 /** Service number for service special entries */
59 service_id_t svc;
60};
61
62/** File list.
63 *
64 * Allows browsing files and directories.
65 */
66typedef struct ui_file_list {
67 /** Base control object */
68 struct ui_control *control;
69
70 /** Containing window */
71 struct ui_window *window;
72
73 /** UI list */
74 ui_list_t *list;
75
76 /** Callbacks */
77 struct ui_file_list_cb *cb;
78
79 /** Callback argument */
80 void *cb_arg;
81
82 /** Directory-type entry color */
83 gfx_color_t *dir_color;
84
85 /** Service-type entry color */
86 gfx_color_t *svc_color;
87
88 /** Directory */
89 char *dir;
90} ui_file_list_t;
91
92extern bool ui_file_list_is_active(ui_file_list_t *);
93extern void ui_file_list_entry_destroy(ui_file_list_entry_t *);
94extern void ui_file_list_clear_entries(ui_file_list_t *);
95extern errno_t ui_file_list_sort(ui_file_list_t *);
96extern int ui_file_list_entry_ptr_cmp(const void *, const void *);
97extern void ui_file_list_entry_attr_init(ui_file_list_entry_attr_t *);
98extern errno_t ui_file_list_entry_append(ui_file_list_t *,
99 ui_file_list_entry_attr_t *);
100extern ui_file_list_entry_t *ui_file_list_first(ui_file_list_t *);
101extern ui_file_list_entry_t *ui_file_list_last(ui_file_list_t *);
102extern ui_file_list_entry_t *ui_file_list_next(ui_file_list_entry_t *);
103extern ui_file_list_entry_t *ui_file_list_prev(ui_file_list_entry_t *);
104extern errno_t ui_file_list_open_dir(ui_file_list_t *, ui_file_list_entry_t *);
105extern errno_t ui_file_list_open_file(ui_file_list_t *, ui_file_list_entry_t *);
106extern void ui_file_list_activate_req(ui_file_list_t *);
107extern void ui_file_list_selected(ui_file_list_t *, const char *);
108extern errno_t ui_file_list_paint(ui_file_list_t *);
109extern int ui_file_list_list_compare(ui_list_entry_t *, ui_list_entry_t *);
110
111#endif
112
113/** @}
114 */
Note: See TracBrowser for help on using the repository browser.