Skip to content

Commit 472a17f

Browse files
authored
Update window.vala
1 parent cb1587e commit 472a17f

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

ui/src/window.vala

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ using GLib;
44

55
public class SecurityModeWindow : Gtk.Window {
66
private const string TMP_DIR = "/tmp/Security-Mode";
7-
87
private Gtk.ComboBoxText profile_combo;
98
private Gtk.Button start_button;
109
private Gtk.Button stop_button;
@@ -13,10 +12,10 @@ public class SecurityModeWindow : Gtk.Window {
1312
private Gtk.TextView log_view;
1413

1514
public SecurityModeWindow () {
16-
Object (
15+
GLib.Object (
1716
title: "Security Mode UI",
1817
default_width: 600,
19-
default_height: 400
18+
default_height: 400
2019
);
2120

2221
var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
@@ -69,11 +68,11 @@ public class SecurityModeWindow : Gtk.Window {
6968
string profile = profile_combo.get_active_text ();
7069
if (profile != null) {
7170
var data = new Json.Builder ()
72-
.begin_object ()
73-
.set_member_name ("command").add_string_value ("start")
74-
.set_member_name ("profile").add_string_value (profile)
75-
.set_member_name ("timestamp").add_string_value (new DateTime.now_utc ().to_string ())
76-
.end_object ();
71+
.begin_object ()
72+
.set_member_name ("command").add_string_value ("start")
73+
.set_member_name ("profile").add_string_value (profile)
74+
.set_member_name ("timestamp").add_string_value (new DateTime.now_utc ().to_string ())
75+
.end_object ();
7776

7877
write_json_file ("start.json", data.get_root ().get_object ());
7978
update_log ("Started with profile: " + profile);
@@ -82,10 +81,10 @@ public class SecurityModeWindow : Gtk.Window {
8281

8382
private void on_stop_clicked () {
8483
var data = new Json.Builder ()
85-
.begin_object ()
86-
.set_member_name ("command").add_string_value ("stop")
87-
.set_member_name ("timestamp").add_string_value (new DateTime.now_utc ().to_string ())
88-
.end_object ();
84+
.begin_object ()
85+
.set_member_name ("command").add_string_value ("stop")
86+
.set_member_name ("timestamp").add_string_value (new DateTime.now_utc ().to_string ())
87+
.end_object ();
8988

9089
write_json_file ("stop.json", data.get_root ().get_object ());
9190
update_log ("Stopped Security Mode");
@@ -97,10 +96,10 @@ public class SecurityModeWindow : Gtk.Window {
9796

9897
private void on_logs_clicked () {
9998
var data = new Json.Builder ()
100-
.begin_object ()
101-
.set_member_name ("command").add_string_value ("logs")
102-
.set_member_name ("timestamp").add_string_value (new DateTime.now_utc ().to_string ())
103-
.end_object ();
99+
.begin_object ()
100+
.set_member_name ("command").add_string_value ("logs")
101+
.set_member_name ("timestamp").add_string_value (new DateTime.now_utc ().to_string ())
102+
.end_object ();
104103

105104
write_json_file ("logs_request.json", data.get_root ().get_object ());
106105
update_log ("Logs requested. Check logs.json later.");
@@ -127,9 +126,11 @@ public class SecurityModeWindow : Gtk.Window {
127126

128127
private void write_json_file (string filename, Json.Object data) {
129128
ensure_tmp_dir ();
130-
var path = Path.build_filename (TMP_DIR, filename);
129+
var path = GLib.Path.build_filename (TMP_DIR, filename);
131130
var generator = new Json.Generator ();
132-
generator.set_root (new Json.Node.alloc ().set_object (data));
131+
var node = new Json.Node.alloc ();
132+
node.set_object (data);
133+
generator.set_root (node);
133134
try {
134135
generator.to_file (path);
135136
stdout.printf ("Wrote JSON to %s\n", path);
@@ -140,7 +141,7 @@ public class SecurityModeWindow : Gtk.Window {
140141

141142
private Json.Object? read_json_file (string filename) {
142143
ensure_tmp_dir ();
143-
var path = Path.build_filename (TMP_DIR, filename);
144+
var path = GLib.Path.build_filename (TMP_DIR, filename);
144145
if (FileUtils.test (path, FileTest.EXISTS)) {
145146
try {
146147
var parser = new Json.Parser ();

0 commit comments

Comments
 (0)