Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 2 files changed
  • 5 comments
  • 1 contributor
56  src/gui/cp.c
@@ -17,6 +17,7 @@
17 17
 
18 18
 #include <rtems.h>
19 19
 #include <stdio.h>
  20
+#include <libgen.h>
20 21
 #include <mtklib.h>
21 22
 
22 23
 #include "performance.h"
@@ -52,19 +53,17 @@ static int appid;
52 53
 static struct filedialog *load_dlg;
53 54
 static struct filedialog *save_dlg;
54 55
 
55  
-static int changed;
  56
+static char default_config[8192] = "/ssd/default.per";
56 57
 
57 58
 void cp_notify_changed(void)
58 59
 {
59  
-	if(changed) return;
60  
-	changed = 1;
61  
-	mtk_cmd(appid, "w.set(-title \"Control panel *\")");
62  
-}
  60
+	if(!strcmp(default_config, "/ssd/default.per"))
  61
+		mtk_cmd(appid, "w.set(-title \"Control panel\")");
  62
+	else
  63
+		mtk_cmdf(appid, "w.set(-title \"\e%s\")",
  64
+			 basename(default_config));
63 65
 
64  
-static void clear_changed(void)
65  
-{
66  
-	mtk_cmd(appid, "w.set(-title \"Control panel\")");
67  
-	changed = 0;
  66
+	config_save(default_config);
68 67
 }
69 68
 
70 69
 static void on_config_change(void)
@@ -77,15 +76,19 @@ static void on_config_change(void)
77 76
 
78 77
 static void loadok_callback(void *arg)
79 78
 {
80  
-	char buf[8192];
  79
+	char buf[4096];
81 80
 
82  
-	get_filedialog_selection(load_dlg, buf, 8192);
  81
+	get_filedialog_selection(load_dlg, buf, sizeof(buf));
83 82
 	if(!config_load(buf)) {
84  
-		messagebox("Performance load", "Unable to load the performance file");
  83
+		messagebox("Performance load",
  84
+			   "Unable to load the performance file");
85 85
 		return;
86 86
 	}
  87
+
  88
+	strcpy(default_config, buf);
  89
+
87 90
 	on_config_change();
88  
-	clear_changed();
  91
+	cp_notify_changed();
89 92
 }
90 93
 
91 94
 static void saveok_callback(void *arg)
@@ -93,8 +96,12 @@ static void saveok_callback(void *arg)
93 96
 	char buf[4096];
94 97
 
95 98
 	get_filedialog_selection(save_dlg, buf, sizeof(buf));
  99
+
96 100
 	config_save(buf);
97  
-	clear_changed();
  101
+
  102
+	strcpy(default_config, buf);
  103
+	on_config_change();
  104
+	cp_notify_changed();
98 105
 }
99 106
 
100 107
 enum {
@@ -112,7 +119,6 @@ enum {
112 119
 	CP_ITEM_EDITOR,
113 120
 	CP_ITEM_MONITOR,
114 121
 
115  
-	CP_ITEM_NEW,
116 122
 	CP_ITEM_LOAD,
117 123
 	CP_ITEM_SAVE,
118 124
 	CP_ITEM_FIRSTPATCH,
@@ -165,17 +171,13 @@ static void cp_callback(mtk_event *e, void *arg)
165 171
 			open_monitor_window();
166 172
 			break;
167 173
 
168  
-		case CP_ITEM_NEW:
169  
-			config_free();
170  
-			on_config_change();
171  
-			clear_changed();
172  
-			break;
173 174
 		case CP_ITEM_LOAD:
174 175
 			open_filedialog(load_dlg);
175 176
 			break;
176 177
 		case CP_ITEM_SAVE:
177 178
 			open_filedialog(save_dlg);
178 179
 			break;
  180
+
179 181
 		case CP_ITEM_FIRSTPATCH:
180 182
 			open_firstpatch_window();
181 183
 			break;
@@ -279,14 +281,12 @@ void init_cp(void)
279 281
 		"g_performance0.place(l_performance, -column 2 -row 1)",
280 282
 		"g_performance0.place(s_performance2, -column 3 -row 1)",
281 283
 		"g_performance = new Grid()",
282  
-		"b_new = new Button(-text \"New\")",
283 284
 		"b_load = new Button(-text \"Load\")",
284  
-		"b_save = new Button(-text \"Save\")",
  285
+		"b_save = new Button(-text \"Save as\")",
285 286
 		"b_firstpatch = new Button(-text \"First patch\")",
286 287
 		"b_start = new Button(-text \"Start\")",
287  
-		"g_performance.place(b_new, -column 1 -row 1)",
288  
-		"g_performance.place(b_load, -column 2 -row 1)",
289  
-		"g_performance.place(b_save, -column 3 -row 1)",
  288
+		"g_performance.place(b_load, -column 1 -row 1)",
  289
+		"g_performance.place(b_save, -column 2 -row 1)",
290 290
 		"g.place(g_performance0, -column 1 -row 8)",
291 291
 		"g.place(g_performance, -column 1 -row 9)",
292 292
 		"g.place(b_firstpatch, -column 1 -row 10)",
@@ -344,7 +344,6 @@ void init_cp(void)
344 344
 	mtk_bind(appid, "b_webupdate", "commit", cp_callback, (void *)CP_ITEM_WEBUPDATE);
345 345
 	mtk_bind(appid, "b_editor", "commit", cp_callback, (void *)CP_ITEM_EDITOR);
346 346
 	mtk_bind(appid, "b_monitor", "commit", cp_callback, (void *)CP_ITEM_MONITOR);
347  
-	mtk_bind(appid, "b_new", "commit", cp_callback, (void *)CP_ITEM_NEW);
348 347
 	mtk_bind(appid, "b_load", "commit", cp_callback, (void *)CP_ITEM_LOAD);
349 348
 	mtk_bind(appid, "b_save", "commit", cp_callback, (void *)CP_ITEM_SAVE);
350 349
 	mtk_bind(appid, "b_firstpatch", "commit", cp_callback, (void *)CP_ITEM_FIRSTPATCH);
@@ -361,6 +360,9 @@ void init_cp(void)
361 360
 
362 361
 	load_dlg = create_filedialog("Load performance", 0, "per", loadok_callback, NULL, NULL, NULL);
363 362
 	save_dlg = create_filedialog("Save performance", 1, "per", saveok_callback, NULL, NULL, NULL);
  363
+
  364
+	config_load(default_config);
  365
+	on_config_change();
364 366
 }
365 367
 
366 368
 void cp_autostart(void)
@@ -388,6 +390,8 @@ void cp_autostart(void)
388 390
 				return;
389 391
 			}
390 392
 			on_config_change();
  393
+			strcpy(default_config, autostart);
  394
+			cp_notify_changed();
391 395
 			start_performance(0, 0, 0);
392 396
 			break;
393 397
 	}
9  src/shortcuts.c
@@ -29,6 +29,7 @@
29 29
 #include "fb.h"
30 30
 #include "gui/guirender.h"
31 31
 #include "gui/flash.h"
  32
+#include "gui/cp.h"
32 33
 #include "shortcuts.h"
33 34
 #include "renderer/osd.h"
34 35
 
@@ -48,6 +49,7 @@ static void help(void)
48 49
 		"F5 / F6: Increase/decrease brightness",
49 50
 		"F7 / F8: Increase/decrease contrast",
50 51
 		"Ctrl+Esc: Exit fun",
  52
+		"Ctrl+Enter: Start rendering",
51 53
 		"F1: Show patch name(simple mode)",
52 54
 		"F9 / RIGHT: Next patch(simple mode)",
53 55
 		"F11 / LEFT: Previous patch(simple mode)",
@@ -79,6 +81,11 @@ static void switch_resolution(void)
79 81
 	}
80 82
 }
81 83
 
  84
+static void autostart(void)
  85
+{
  86
+	if(!fb_get_mode()) cp_autostart();
  87
+}
  88
+
82 89
 static void shortcuts_callback(mtk_event *e, int count)
83 90
 {
84 91
 	int i;
@@ -105,6 +112,8 @@ static void shortcuts_callback(mtk_event *e, int count)
105 112
 				clean_shutdown(1);
106 113
 			else if(ctrl && (e[i].press.code == MTK_KEY_F1))
107 114
 				switch_resolution();
  115
+			else if(ctrl && (e[i].press.code == MTK_KEY_ENTER))
  116
+				autostart();
108 117
 			else if(e[i].press.code == MTK_KEY_SYSRQ)
109 118
 				fbgrab(NULL);
110 119
 			else if(ctrl && (e[i].press.code == MTK_KEY_H))

Showing you all comments on commits in this comparison.

Sébastien Bourdeauducq
Owner

Remove the translations as well.

Sébastien Bourdeauducq
Owner

Is that necessary?

Sébastien Bourdeauducq
Owner

cp_notify_changed() does that already (unless you call that future function that only sets the window title, which would be less confusing).

Sébastien Bourdeauducq
Owner

Better to break down that cp_notify_changed() into one that only sets the window title, and another one that also saves the file.

Sébastien Bourdeauducq
Owner

Again - no need to save the file here.

Something went wrong with that request. Please try again.