Changeset 516c160 in mainline
- Timestamp:
- 2021-10-16T23:08:02Z (3 years ago)
- Children:
- 9468680
- Parents:
- 75357c5
- Location:
- uspace/app/nav
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nav/panel.c
r75357c5 r516c160 41 41 #include <stdlib.h> 42 42 #include <str.h> 43 #include <task.h> 43 44 #include <ui/control.h> 44 45 #include <ui/paint.h> … … 953 954 errno_t panel_open(panel_t *panel, panel_entry_t *entry) 954 955 { 956 if (entry->isdir) 957 return panel_open_dir(panel, entry); 958 else if (entry->svc == 0) 959 return panel_open_file(panel, entry); 960 else 961 return EOK; 962 } 963 964 /** Open panel directory entry. 965 * 966 * Perform Open action on a directory entry (i.e. switch to the directory). 967 * 968 * @param panel Panel 969 * @param entry Panel entry (which is a directory) 970 * 971 * @return EOK on success or an error code 972 */ 973 errno_t panel_open_dir(panel_t *panel, panel_entry_t *entry) 974 { 955 975 gfx_context_t *gc = ui_window_get_gc(panel->window); 956 char *dirname;957 976 errno_t rc; 958 977 959 if (!entry->isdir) 960 return EOK; 961 962 dirname = str_dup(entry->name); 978 assert(entry->isdir); 979 963 980 panel_clear_entries(panel); 964 981 965 rc = panel_read_dir(panel, dirname); 966 if (rc != EOK) { 967 free(dirname); 968 return rc; 969 } 982 rc = panel_read_dir(panel, entry->name); 983 if (rc != EOK) 984 return rc; 970 985 971 986 rc = panel_paint(panel); 972 if (rc != EOK) { 973 free(dirname); 974 return rc; 975 } 976 977 free(dirname); 987 if (rc != EOK) 988 return rc; 989 978 990 return gfx_update(gc); 979 991 } 980 992 993 /** Open panel file entry. 994 * 995 * Perform Open action on a file entry (i.e. try running it). 996 * 997 * @param panel Panel 998 * @param entry Panel entry (which is a file) 999 * 1000 * @return EOK on success or an error code 1001 */ 1002 errno_t panel_open_file(panel_t *panel, panel_entry_t *entry) 1003 { 1004 task_id_t id; 1005 task_wait_t wait; 1006 task_exit_t texit; 1007 int retval; 1008 errno_t rc; 1009 1010 /* It's not a directory */ 1011 assert(!entry->isdir); 1012 /* It's not a service-special file */ 1013 assert(entry->svc == 0); 1014 1015 rc = task_spawnl(&id, &wait, entry->name, entry->name, NULL); 1016 if (rc != EOK) 1017 return rc; 1018 1019 rc = task_wait(&wait, &texit, &retval); 1020 if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) 1021 return rc; 1022 1023 (void) ui_paint(ui_window_get_ui(panel->window)); 1024 return EOK; 1025 } 1026 981 1027 /** @} 982 1028 */ -
uspace/app/nav/panel.h
r75357c5 r516c160 77 77 extern void panel_page_down(panel_t *); 78 78 extern errno_t panel_open(panel_t *, panel_entry_t *); 79 extern errno_t panel_open_dir(panel_t *, panel_entry_t *); 80 extern errno_t panel_open_file(panel_t *, panel_entry_t *); 79 81 80 82 #endif
Note:
See TracChangeset
for help on using the changeset viewer.