Changeset 550ed86 in mainline
- Timestamp:
- 2023-12-19T17:25:58Z (14 months ago)
- Branches:
- master, topic/simplify-dev-export
- Children:
- 7130754
- Parents:
- f87ff8e
- git-author:
- Jiri Svoboda <jiri@…> (2023-12-19 17:19:18)
- git-committer:
- Jiri Svoboda <jiri@…> (2023-12-19 17:25:58)
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar-cfg/smeedit.c
rf87ff8e r550ed86 116 116 117 117 ui_wnd_params_init(¶ms); 118 params.caption = smentry != NULL ? "Edit Start Menu Entry" 119 :"Create Start Menu Entry";118 params.caption = smentry != NULL ? "Edit Start Menu Entry" : 119 "Create Start Menu Entry"; 120 120 if (ui_is_textmode(ui)) { 121 121 params.rect.p0.x = 0; … … 345 345 { 346 346 smeedit_t *smee; 347 smenu_entry_t *entry; 348 startmenu_entry_t *smentry; 347 349 const char *cmd; 348 350 const char *caption; … … 358 360 /* Create new entry */ 359 361 rc = smenu_entry_create(smee->startmenu->tbarcfg->tbarcfg, 360 caption, cmd );362 caption, cmd, &entry); 361 363 if (rc != EOK) 362 364 return; 365 366 rc = startmenu_insert(smee->startmenu, entry, &smentry); 367 if (rc != EOK) 368 return; 369 370 startmenu_repaint(smee->startmenu); 363 371 } else { 364 372 /* Edit existing entry */ 365 366 367 373 rc = smenu_entry_set_cmd(smee->smentry->entry, cmd); 368 374 if (rc != EOK) -
uspace/app/taskbar-cfg/startmenu.c
rf87ff8e r550ed86 429 429 } 430 430 431 /** Repaint start menu entry list. 432 * 433 * When editing an entry the entry's label might change. We need 434 * to update the list entry caption to reflect that. 435 * 436 * @param smenu Start menu 437 */ 438 void startmenu_repaint(startmenu_t *smenu) 439 { 440 (void) ui_control_paint(ui_list_ctl(smenu->entries_list)); 441 } 442 431 443 /** Entry in entry list is selected. 432 444 * -
uspace/app/taskbar-cfg/startmenu.h
rf87ff8e r550ed86 50 50 extern void startmenu_edit(startmenu_t *); 51 51 extern errno_t startmenu_entry_update(startmenu_entry_t *); 52 extern void startmenu_repaint(startmenu_t *); 52 53 53 54 #endif -
uspace/lib/tbarcfg/include/tbarcfg/tbarcfg.h
rf87ff8e r550ed86 51 51 extern errno_t smenu_entry_set_cmd(smenu_entry_t *, const char *); 52 52 extern errno_t smenu_entry_save(smenu_entry_t *); 53 extern errno_t smenu_entry_create(tbarcfg_t *, const char *, const char *); 53 extern errno_t smenu_entry_create(tbarcfg_t *, const char *, const char *, 54 smenu_entry_t **); 54 55 extern errno_t smenu_entry_destroy(smenu_entry_t *); 55 56 -
uspace/lib/tbarcfg/private/tbarcfg.h
rf87ff8e r550ed86 67 67 68 68 extern errno_t smenu_entry_new(tbarcfg_t *, sif_node_t *, const char *, 69 const char * );69 const char *, smenu_entry_t **); 70 70 extern void smenu_entry_delete(smenu_entry_t *); 71 71 -
uspace/lib/tbarcfg/src/tbarcfg.c
rf87ff8e r550ed86 154 154 } 155 155 156 rc = smenu_entry_new(tbcfg, nentry, caption, cmd );156 rc = smenu_entry_new(tbcfg, nentry, caption, cmd, NULL); 157 157 if (rc != EOK) 158 158 goto error; … … 325 325 * @param caption Caption 326 326 * @param cmd Command to run 327 * @param rentry Place to store pointer to new entry or @c NULL 327 328 */ 328 329 errno_t smenu_entry_new(tbarcfg_t *smenu, sif_node_t *nentry, 329 const char *caption, const char *cmd )330 const char *caption, const char *cmd, smenu_entry_t **rentry) 330 331 { 331 332 smenu_entry_t *entry; … … 354 355 entry->smenu = smenu; 355 356 list_append(&entry->lentries, &smenu->entries); 357 if (rentry != NULL) 358 *rentry = entry; 356 359 return EOK; 357 360 error: … … 388 391 * @param caption Caption 389 392 * @param cmd Command to run 393 * @param rentry Place to store pointer to new entry or @c NULL 390 394 */ 391 395 errno_t smenu_entry_create(tbarcfg_t *smenu, const char *caption, 392 const char *cmd )396 const char *cmd, smenu_entry_t **rentry) 393 397 { 394 398 sif_node_t *nentry; 399 smenu_entry_t *entry; 395 400 errno_t rc; 396 401 sif_trans_t *trans = NULL; … … 413 418 goto error; 414 419 415 rc = smenu_entry_new(smenu, nentry, caption, cmd );420 rc = smenu_entry_new(smenu, nentry, caption, cmd, &entry); 416 421 if (rc != EOK) 417 422 goto error; … … 421 426 goto error; 422 427 428 if (rentry != NULL) 429 *rentry = entry; 423 430 return EOK; 424 431 error: -
uspace/lib/tbarcfg/test/tbarcfg.c
rf87ff8e r550ed86 67 67 tbarcfg_t *tbcfg; 68 68 char fname[L_tmpnam], *p; 69 smenu_entry_t *e; 70 71 p = tmpnam(fname); 72 PCUT_ASSERT_NOT_NULL(p); 73 74 rc = tbarcfg_create(fname, &tbcfg); 75 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 76 77 rc = smenu_entry_create(tbcfg, "A", "a"); 78 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 79 80 rc = smenu_entry_create(tbcfg, "B", "b"); 69 smenu_entry_t *e1 = NULL, *e2 = NULL; 70 smenu_entry_t *e; 71 72 p = tmpnam(fname); 73 PCUT_ASSERT_NOT_NULL(p); 74 75 rc = tbarcfg_create(fname, &tbcfg); 76 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 77 78 rc = smenu_entry_create(tbcfg, "A", "a", &e1); 79 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 80 PCUT_ASSERT_NOT_NULL(e1); 81 82 rc = smenu_entry_create(tbcfg, "B", "b", &e2); 83 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 84 PCUT_ASSERT_NOT_NULL(e2); 85 86 /* Create entry without getting a pointer to it */ 87 rc = smenu_entry_create(tbcfg, "C", "c", NULL); 81 88 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 82 89 83 90 e = tbarcfg_smenu_first(tbcfg); 84 PCUT_ASSERT_NOT_NULL(e); 91 PCUT_ASSERT_EQUALS(e1, e); 92 e = tbarcfg_smenu_next(e); 93 PCUT_ASSERT_EQUALS(e2, e); 85 94 e = tbarcfg_smenu_next(e); 86 95 PCUT_ASSERT_NOT_NULL(e); … … 108 117 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 109 118 110 rc = smenu_entry_create(tbcfg, "A", "a"); 119 rc = smenu_entry_create(tbcfg, "A", "a", &e); 120 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 121 122 caption = smenu_entry_get_caption(e); 123 PCUT_ASSERT_STR_EQUALS("A", caption); 124 cmd = smenu_entry_get_cmd(e); 125 PCUT_ASSERT_STR_EQUALS("a", cmd); 126 127 tbarcfg_close(tbcfg); 128 remove(fname); 129 } 130 131 /** Setting menu entry properties */ 132 PCUT_TEST(set_caption_cmd) 133 { 134 errno_t rc; 135 tbarcfg_t *tbcfg; 136 char fname[L_tmpnam], *p; 137 smenu_entry_t *e; 138 const char *caption; 139 const char *cmd; 140 141 p = tmpnam(fname); 142 PCUT_ASSERT_NOT_NULL(p); 143 144 rc = tbarcfg_create(fname, &tbcfg); 145 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 146 147 rc = smenu_entry_create(tbcfg, "A", "a", &e); 148 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 149 150 caption = smenu_entry_get_caption(e); 151 PCUT_ASSERT_STR_EQUALS("A", caption); 152 cmd = smenu_entry_get_cmd(e); 153 PCUT_ASSERT_STR_EQUALS("a", cmd); 154 155 /* Set properties */ 156 rc = smenu_entry_set_caption(e, "B"); 157 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 158 rc = smenu_entry_set_cmd(e, "b"); 159 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 160 161 rc = smenu_entry_save(e); 162 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 163 164 /* Check that properties have been set */ 165 caption = smenu_entry_get_caption(e); 166 PCUT_ASSERT_STR_EQUALS("B", caption); 167 cmd = smenu_entry_get_cmd(e); 168 PCUT_ASSERT_STR_EQUALS("b", cmd); 169 170 tbarcfg_close(tbcfg); 171 172 /* Re-open repository */ 173 174 rc = tbarcfg_open(fname, &tbcfg); 111 175 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 112 176 … … 114 178 PCUT_ASSERT_NOT_NULL(e); 115 179 116 caption = smenu_entry_get_caption(e); 117 PCUT_ASSERT_STR_EQUALS("A", caption); 118 cmd = smenu_entry_get_cmd(e); 119 PCUT_ASSERT_STR_EQUALS("a", cmd); 120 121 tbarcfg_close(tbcfg); 122 remove(fname); 123 } 124 125 /** Setting menu entry properties */ 126 PCUT_TEST(set_caption_cmd) 180 /* Check that new values of properties have persisted */ 181 caption = smenu_entry_get_caption(e); 182 PCUT_ASSERT_STR_EQUALS("B", caption); 183 cmd = smenu_entry_get_cmd(e); 184 PCUT_ASSERT_STR_EQUALS("b", cmd); 185 186 tbarcfg_close(tbcfg); 187 remove(fname); 188 } 189 190 /** Create start menu entry */ 191 PCUT_TEST(entry_create) 127 192 { 128 193 errno_t rc; … … 139 204 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 140 205 141 rc = smenu_entry_create(tbcfg, "A", "a"); 142 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 143 144 e = tbarcfg_smenu_first(tbcfg); 145 PCUT_ASSERT_NOT_NULL(e); 146 147 caption = smenu_entry_get_caption(e); 148 PCUT_ASSERT_STR_EQUALS("A", caption); 149 cmd = smenu_entry_get_cmd(e); 150 PCUT_ASSERT_STR_EQUALS("a", cmd); 151 152 /* Set properties */ 153 rc = smenu_entry_set_caption(e, "B"); 154 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 155 rc = smenu_entry_set_cmd(e, "b"); 156 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 157 158 rc = smenu_entry_save(e); 159 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 160 161 /* Check that properties have been set */ 162 caption = smenu_entry_get_caption(e); 163 PCUT_ASSERT_STR_EQUALS("B", caption); 164 cmd = smenu_entry_get_cmd(e); 165 PCUT_ASSERT_STR_EQUALS("b", cmd); 166 167 tbarcfg_close(tbcfg); 168 169 /* Re-open repository */ 170 171 rc = tbarcfg_open(fname, &tbcfg); 172 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 173 174 e = tbarcfg_smenu_first(tbcfg); 175 PCUT_ASSERT_NOT_NULL(e); 176 177 /* Check that new values of properties have persisted */ 178 caption = smenu_entry_get_caption(e); 179 PCUT_ASSERT_STR_EQUALS("B", caption); 180 cmd = smenu_entry_get_cmd(e); 181 PCUT_ASSERT_STR_EQUALS("b", cmd); 182 183 tbarcfg_close(tbcfg); 184 remove(fname); 185 } 186 187 /** Create start menu entry */ 188 PCUT_TEST(entry_create) 189 { 190 errno_t rc; 191 tbarcfg_t *tbcfg; 192 char fname[L_tmpnam], *p; 193 smenu_entry_t *e; 194 const char *caption; 195 const char *cmd; 196 197 p = tmpnam(fname); 198 PCUT_ASSERT_NOT_NULL(p); 199 200 rc = tbarcfg_create(fname, &tbcfg); 201 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 202 203 rc = smenu_entry_create(tbcfg, "A", "a"); 204 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 205 206 e = tbarcfg_smenu_first(tbcfg); 206 rc = smenu_entry_create(tbcfg, "A", "a", &e); 207 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 207 208 PCUT_ASSERT_NOT_NULL(e); 208 209 … … 222 223 tbarcfg_t *tbcfg; 223 224 char fname[L_tmpnam], *p; 224 smenu_entry_t *e ;225 226 p = tmpnam(fname); 227 PCUT_ASSERT_NOT_NULL(p); 228 229 rc = tbarcfg_create(fname, &tbcfg); 230 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 231 232 rc = smenu_entry_create(tbcfg, "A", "a" );233 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 234 235 e= tbarcfg_smenu_first(tbcfg);236 PCUT_ASSERT_ NOT_NULL(e);225 smenu_entry_t *e, *f; 226 227 p = tmpnam(fname); 228 PCUT_ASSERT_NOT_NULL(p); 229 230 rc = tbarcfg_create(fname, &tbcfg); 231 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 232 233 rc = smenu_entry_create(tbcfg, "A", "a", &e); 234 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 235 236 f = tbarcfg_smenu_first(tbcfg); 237 PCUT_ASSERT_EQUALS(e, f); 237 238 238 239 rc = smenu_entry_destroy(e); 239 240 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 240 241 241 e= tbarcfg_smenu_first(tbcfg);242 PCUT_ASSERT_NULL( e);242 f = tbarcfg_smenu_first(tbcfg); 243 PCUT_ASSERT_NULL(f); 243 244 244 245 tbarcfg_close(tbcfg);
Note:
See TracChangeset
for help on using the changeset viewer.