Changeset 8e253ac in mainline
- Timestamp:
- 2021-09-25T21:01:28Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b4b5f6a4
- Parents:
- 45b7d4d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
r45b7d4d r8e253ac 55 55 #include <types/common.h> 56 56 #include <ui/control.h> 57 #include <ui/filedialog.h> 57 58 #include <ui/fixed.h> 58 59 #include <ui/label.h> … … 255 256 .paint = pane_ctl_paint, 256 257 .pos_event = pane_ctl_pos_event 258 }; 259 260 static void save_as_dialog_bok(ui_file_dialog_t *, void *, const char *); 261 static void save_as_dialog_bcancel(ui_file_dialog_t *, void *); 262 static void save_as_dialog_close(ui_file_dialog_t *, void *); 263 264 static ui_file_dialog_cb_t save_as_dialog_cb = { 265 .bok = save_as_dialog_bok, 266 .bcancel = save_as_dialog_bcancel, 267 .close = save_as_dialog_close 257 268 }; 258 269 … … 783 794 } 784 795 785 /** Change document name and save. */796 /** Open Save As dialog. */ 786 797 static void file_save_as(void) 787 798 { 788 const char *old_fname = (doc.file_name != NULL) ? doc.file_name : ""; 789 char *fname; 790 791 fname = prompt("Save As", old_fname); 792 if (fname == NULL) { 793 status_display("Save cancelled."); 799 // const char *old_fname = (doc.file_name != NULL) ? doc.file_name : ""; 800 ui_file_dialog_params_t fdparams; 801 ui_file_dialog_t *dialog; 802 errno_t rc; 803 804 ui_file_dialog_params_init(&fdparams); 805 fdparams.caption = "Save As"; 806 // TODO: Set initial file name to old_fname 807 808 rc = ui_file_dialog_create(edit.ui, &fdparams, &dialog); 809 if (rc != EOK) { 810 printf("Error creating message dialog.\n"); 794 811 return; 795 812 } 796 813 797 errno_t rc = file_save(fname); 798 if (rc != EOK) 799 return; 800 801 if (doc.file_name != NULL) 802 free(doc.file_name); 803 doc.file_name = fname; 814 ui_file_dialog_set_cb(dialog, &save_as_dialog_cb, &edit); 804 815 } 805 816 … … 2111 2122 } 2112 2123 2124 /** Save As dialog OK button press. 2125 * 2126 * @param dialog Save As dialog 2127 * @param arg Argument (ui_demo_t *) 2128 * @param fname File name 2129 */ 2130 static void save_as_dialog_bok(ui_file_dialog_t *dialog, void *arg, 2131 const char *fname) 2132 { 2133 char *cname; 2134 errno_t rc; 2135 2136 ui_file_dialog_destroy(dialog); 2137 2138 cname = str_dup(fname); 2139 if (cname == NULL) { 2140 printf("Out of memory.\n"); 2141 return; 2142 } 2143 2144 rc = file_save(fname); 2145 if (rc != EOK) 2146 return; 2147 2148 if (doc.file_name != NULL) 2149 free(doc.file_name); 2150 doc.file_name = cname; 2151 2152 } 2153 2154 /** Save As dialog cancel button press. 2155 * 2156 * @param dialog File dialog 2157 * @param arg Argument (ui_demo_t *) 2158 */ 2159 static void save_as_dialog_bcancel(ui_file_dialog_t *dialog, void *arg) 2160 { 2161 edit_t *edit = (edit_t *)arg; 2162 2163 (void)edit; 2164 ui_file_dialog_destroy(dialog); 2165 } 2166 2167 /** Save As dialog close request. 2168 * 2169 * @param dialog File dialog 2170 * @param arg Argument (ui_demo_t *) 2171 */ 2172 static void save_as_dialog_close(ui_file_dialog_t *dialog, void *arg) 2173 { 2174 edit_t *edit = (edit_t *)arg; 2175 2176 (void)edit; 2177 ui_file_dialog_destroy(dialog); 2178 } 2179 2113 2180 /** @} 2114 2181 */
Note:
See TracChangeset
for help on using the changeset viewer.