summaryrefslogtreecommitdiffstats
path: root/ScreensPanel.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2018-01-28 17:06:53 -0200
committerHisham Muhammad <hisham@gobolinux.org>2018-01-30 12:59:11 -0200
commit5ea24db29cad0cbd437079a97ac50e1362062b42 (patch)
treeb23609d54ff7a9d4df73842163a4507b07ae7433 /ScreensPanel.c
parent42d50f1b9f0868d87b933569365584ea165587a2 (diff)
Screens: Fix "New Screen" option
Diffstat (limited to 'ScreensPanel.c')
-rw-r--r--ScreensPanel.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/ScreensPanel.c b/ScreensPanel.c
index 19ac96bd..1fe6283f 100644
--- a/ScreensPanel.c
+++ b/ScreensPanel.c
@@ -53,9 +53,9 @@ ObjectClass ScreenListItem_class = {
.compare = ListItem_compare
};
-ScreenListItem* ScreenListItem_new(const char* value, int key, ScreenSettings* ss) {
+ScreenListItem* ScreenListItem_new(const char* value, ScreenSettings* ss) {
ScreenListItem* this = AllocThis(ScreenListItem);
- ListItem_init((ListItem*)this, value, key);
+ ListItem_init((ListItem*)this, value, 0);
this->ss = ss;
return this;
}
@@ -150,6 +150,17 @@ static void rebuildSettingsArray(Panel* super) {
}
}
+static void addNewScreen(Panel* super) {
+ ScreensPanel* const this = (ScreensPanel*) super;
+
+ char* name = "New";
+ ScreenSettings* ss = Settings_newScreen(this->settings, name, "PID Command");
+ ScreenListItem* item = ScreenListItem_new(name, ss);
+ int idx = Panel_getSelectedIndex(super);
+ Panel_insert(super, idx + 1, (Object*) item);
+ Panel_setSelected(super, idx + 1);
+}
+
static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) {
ScreensPanel* const this = (ScreensPanel*) super;
@@ -190,10 +201,7 @@ static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) {
case KEY_F(5):
case KEY_CTRL('N'):
{
- ListItem* item = ListItem_new("", 0);
- int idx = Panel_getSelectedIndex(super);
- Panel_insert(super, idx + 1, (Object*) item);
- Panel_setSelected(super, idx + 1);
+ addNewScreen(super);
startRenaming(super);
shouldRebuildArray = true;
result = HANDLED;
@@ -300,7 +308,7 @@ ScreensPanel* ScreensPanel_new(Settings* settings) {
for (unsigned int i = 0; i < settings->nScreens; i++) {
ScreenSettings* ss = settings->screens[i];
char* name = ss->name;
- Panel_add(super, (Object*) ScreenListItem_new(name, i, ss));
+ Panel_add(super, (Object*) ScreenListItem_new(name, ss));
}
return this;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy