summaryrefslogtreecommitdiff
path: root/src/user/settings/main.cpp
blob: cb318b1835b421b98897ae78267fcfa80d76004d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "model.h"

#include <raleigh/w/button.h>
#include <raleigh/w/label.h>
#include <raleigh/w/vbox.h>

#define SETTINGS_FILE "/sys/settings.pls"

using namespace raleigh;

void on_button(button_tag_t tag) {
  setting *s = (setting *)tag;
  s->kind->open_editor(*s);
}

void main() {
  settings_model sm(SETTINGS_FILE);

  label instructions("Click a button below to edit that setting.");

  dllist<widget &> box_widgets;
  box_widgets.add_back(instructions);

  for (uint32_t i = 0; i < sm.settings.n_entries; ++i) {
    label *l = new label(sm.settings.buf[i].name);
    button *b = new button(*l, &on_button, (button_tag_t)&sm.settings.buf[i]);
    box_widgets.add_back(*b);
  }

  vbox box(box_widgets);
  window w(box);
  w.show();

  start_runtime();
}