Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 5 commits
  • 4 files changed
  • 0 comments
  • 1 contributor
27  src/gui/filedialog.c
@@ -28,6 +28,8 @@
28 28
 
29 29
 #include "filedialog.h"
30 30
 
  31
+#define ROOT_FOLDER "/ssd/"
  32
+
31 33
 static int cmpstringp(const void *p1, const void *p2)
32 34
 {
33 35
 	return strcmp(*(char * const *)p1, *(char * const *)p2);
@@ -65,12 +67,9 @@ static void display_folder(struct filedialog *dlg, const char *folder)
65 67
 		strncat(fullname, entry->d_name, sizeof(fullname));
66 68
 		lstat(fullname, &s);
67 69
 		if(S_ISDIR(s.st_mode)) {
68  
-			/* hide /dev */
69  
-			if((strcmp(folder, "/") != 0) || (strcmp(entry->d_name, "dev") != 0)) {
70  
-				if(n_folders < 384) {
71  
-					folders[n_folders] = strdup(entry->d_name);
72  
-					n_folders++;
73  
-				}
  70
+			if(n_folders < 384) {
  71
+				folders[n_folders] = strdup(entry->d_name);
  72
+				n_folders++;
74 73
 			}
75 74
 		} else {
76 75
 			/* hide files without the extensions we are looking for
@@ -138,6 +137,12 @@ static void refresh(struct filedialog *dlg)
138 137
 	mtk_cmd(dlg->appid, "fd_filename.set(-text \"\")");
139 138
 }
140 139
 
  140
+static void unlock_callback(mtk_event *e, void *arg)
  141
+{
  142
+	struct filedialog *dlg = arg;
  143
+	dlg->unlock++;
  144
+}
  145
+
141 146
 static void gqf_change_callback(mtk_event *e, void *arg)
142 147
 {
143 148
 	struct filedialog *dlg = arg;
@@ -189,7 +194,7 @@ static void folder_selcommit_callback(mtk_event *e, void *arg)
189 194
 
190 195
 	if(strcmp(selection, "../") == 0) {
191 196
 		char *c;
192  
-		if(strcmp(curfolder, "/") == 0) return;
  197
+		if(strcmp(curfolder, dlg->unlock > 2 ? "/": ROOT_FOLDER) == 0) return;
193 198
 		*(curfolder+strlen(curfolder)-1) = 0;
194 199
 		c = strrchr(curfolder, '/');
195 200
 		c++;
@@ -239,7 +244,7 @@ static void dlg_ok_callback(mtk_event *e, void *arg)
239 244
 	char file[384];
240 245
 
241 246
 	mtk_req(dlg->appid, file, sizeof(file), "fd_filename.text");
242  
-	if(strcmp(file, "") == 0)
  247
+	if((strcmp(file, "") == 0) || (strchr(file, '/') != NULL))
243 248
 		return;
244 249
 	close_filedialog(dlg);
245 250
 	if(dlg->ok_callback)
@@ -266,6 +271,7 @@ struct filedialog *create_filedialog(const char *name, int is_save, const char *
266 271
 	dlg->extfilter = extfilter;
267 272
 	dlg->extfilter2 = "";
268 273
 	dlg->extfilter3 = "";
  274
+	dlg->unlock = 0;
269 275
 	dlg->ok_callback = ok_callback;
270 276
 	dlg->ok_callback_arg = ok_callback_arg;
271 277
 	dlg->cancel_callback = cancel_callback;
@@ -275,7 +281,7 @@ struct filedialog *create_filedialog(const char *name, int is_save, const char *
275 281
 
276 282
 	mtk_cmd(dlg->appid, "fd_g1 = new Grid()");
277 283
 	mtk_cmd(dlg->appid, "fd_g1_s1 = new Separator(-vertical no)");
278  
-	mtk_cmd(dlg->appid, "fd_g1_l = new Label(-text \"\e/\")");
  284
+	mtk_cmd(dlg->appid, "fd_g1_l = new Label(-text \"\e"ROOT_FOLDER"\")");
279 285
 	mtk_cmd(dlg->appid, "fd_g1_s2 = new Separator(-vertical no)");
280 286
 	mtk_cmd(dlg->appid, "fd_g1.place(fd_g1_s1, -column 1 -row 1)");
281 287
 	mtk_cmd(dlg->appid, "fd_g1.place(fd_g1_l, -column 2 -row 1)");
@@ -324,6 +330,8 @@ struct filedialog *create_filedialog(const char *name, int is_save, const char *
324 330
 
325 331
 	mtk_cmdf(dlg->appid, "fd = new Window(-content fd_g -title \"%s\")", name);
326 332
 	
  333
+	mtk_bind(dlg->appid, "fd_g1_l", "press", unlock_callback, (void *)dlg);
  334
+	
327 335
 	mtk_bind(dlg->appid, "fd_gqf_e", "change", gqf_change_callback, (void *)dlg);
328 336
 	mtk_bind(dlg->appid, "fd_gqf_clear", "commit", gqf_clear_callback, (void *)dlg);
329 337
 
@@ -346,6 +354,7 @@ void filedialog_extfilterex(struct filedialog *dlg, const char *extfilter2, cons
346 354
 
347 355
 void open_filedialog(struct filedialog *dlg)
348 356
 {
  357
+	dlg->unlock = 0;
349 358
 	refresh(dlg);
350 359
 	mtk_cmd(dlg->appid, "fd.open()");
351 360
 }
1  src/gui/filedialog.h
@@ -24,6 +24,7 @@ struct filedialog {
24 24
 	const char *extfilter;
25 25
 	const char *extfilter2;
26 26
 	const char *extfilter3;
  27
+	int unlock;
27 28
 	void (*ok_callback)(void *);
28 29
 	void *ok_callback_arg;
29 30
 	void (*cancel_callback)(void *);
26  src/gui/filemanager.c
@@ -29,6 +29,9 @@
29 29
 
30 30
 #include "filemanager.h"
31 31
 
  32
+#define ROOT_FOLDER "/ssd/"
  33
+static int unlock;
  34
+
32 35
 /* Ugly APIs need ugly hacks. */
33 36
 int rtems_shell_main_cp(int argc, char *argv[]);
34 37
 int rtems_shell_main_rm(int argc, char *argv[]);
@@ -186,7 +189,7 @@ static void selcommit_callback(mtk_event *e, void *arg)
186 189
 		get_lfolder(curfolder, sizeof(curfolder), panel);
187 190
 		if(strcmp(sel, "../") == 0) {
188 191
 			char *c;
189  
-			if(strcmp(curfolder, "/") == 0) return;
  192
+			if(strcmp(curfolder, unlock > 2 ? "/": ROOT_FOLDER) == 0) return;
190 193
 			*(curfolder+strlen(curfolder)-1) = 0;
191 194
 			c = strrchr(curfolder, '/');
192 195
 			c++;
@@ -278,6 +281,11 @@ static void close_callback(mtk_event *e, void *arg)
278 281
 	mtk_cmd(appid, "w.close()");
279 282
 }
280 283
 
  284
+static void unlock_callback(mtk_event *e, void *arg)
  285
+{
  286
+	unlock++;
  287
+}
  288
+
281 289
 void init_filemanager()
282 290
 {
283 291
 	appid = mtk_init_app("File manager");
@@ -359,6 +367,8 @@ void init_filemanager()
359 367
 		"w = new Window(-content g -title \"File manager\" -workx 20 -workh 350)",
360 368
 	0);
361 369
 	
  370
+	mtk_bind(appid, "p0_lfolder", "press", unlock_callback, NULL);
  371
+	
362 372
 	mtk_bind(appid, "pc_copy", "press", mode_callback, (void *)0);
363 373
 	mtk_bind(appid, "pc_move", "press", mode_callback, (void *)1);
364 374
 	mtk_bind(appid, "pc_to", "press", to_callback, NULL);
@@ -414,12 +424,9 @@ static void display_folder(int panel, const char *folder)
414 424
 		strncat(fullname, entry->d_name, sizeof(fullname));
415 425
 		lstat(fullname, &s);
416 426
 		if(S_ISDIR(s.st_mode)) {
417  
-			/* hide /dev */
418  
-			if((strcmp(folder, "/") != 0) || (strcmp(entry->d_name, "dev") != 0)) {
419  
-				if(n_folders < 384) {
420  
-					folders[n_folders] = strdup(entry->d_name);
421  
-					n_folders++;
422  
-				}
  427
+			if(n_folders < 384) {
  428
+				folders[n_folders] = strdup(entry->d_name);
  429
+				n_folders++;
423 430
 			}
424 431
 		} else {
425 432
 			files[n_files] = strdup(entry->d_name);
@@ -461,7 +468,8 @@ static void display_folder(int panel, const char *folder)
461 468
 
462 469
 void open_filemanager_window()
463 470
 {
464  
-	display_folder(0, "/");
465  
-	display_folder(1, "/");
  471
+	unlock = 0;
  472
+	display_folder(0, ROOT_FOLDER);
  473
+	display_folder(1, ROOT_FOLDER);
466 474
 	mtk_cmd(appid, "w.open()");
467 475
 }
1  src/main.c
@@ -179,7 +179,6 @@ rtems_task Init(rtems_task_argument argument)
179 179
 	/* FIXME: can this be moved into the initialization table? */
180 180
 	memcard_register();
181 181
 
182  
-	mkdir("/ramdisk", 0777);
183 182
 	/*start_memcard();*/
184 183
 	mkdir("/ssd", 0777);
185 184
 	mount("/dev/flash5", "/ssd", "yaffs", RTEMS_FILESYSTEM_READ_WRITE, "");

No commit comments for this range

Something went wrong with that request. Please try again.