]> git.ipfire.org Git - people/ms/systemd.git/blob - systemadm.vala
service: treat 0 timeouts as no timeouts
[people/ms/systemd.git] / systemadm.vala
1 /***
2 This file is part of systemd.
3
4 Copyright 2010 Lennart Poettering
5
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 ***/
19
20 using Gtk;
21 using GLib;
22 using DBus;
23 using Pango;
24
25 static bool session = false;
26
27 public class LeftLabel : Label {
28 public LeftLabel(string? text = null) {
29 if (text != null)
30 set_markup("<b>%s</b>".printf(text));
31 set_alignment(0, 0);
32 set_padding(6, 0);
33 }
34 }
35
36 public class RightLabel : Label {
37 public RightLabel(string? text = null) {
38 set_text_or_na(text);
39 set_alignment(0, 0);
40 set_ellipsize(EllipsizeMode.START);
41 set_selectable(true);
42 }
43
44 public void set_text_or_na(string? text = null) {
45 if (text == null || text == "")
46 set_markup("<i>n/a</i>");
47 else
48 set_text(text);
49 }
50 }
51
52 public class MainWindow : Window {
53
54 private string? current_unit_id;
55 private uint32 current_job_id;
56
57 private TreeView unit_view;
58 private TreeView job_view;
59
60 private ListStore unit_model;
61 private ListStore job_model;
62
63 private Button start_button;
64 private Button stop_button;
65 private Button restart_button;
66 private Button reload_button;
67 private Button cancel_button;
68
69 private Button server_snapshot_button;
70 private Button server_reload_button;
71
72 private Connection bus;
73 private Manager manager;
74
75 private RightLabel unit_id_label;
76 private RightLabel unit_aliases_label;
77 private RightLabel unit_description_label;
78 private RightLabel unit_load_state_label;
79 private RightLabel unit_active_state_label;
80 private RightLabel unit_sub_state_label;
81 private RightLabel unit_fragment_path_label;
82 private RightLabel unit_active_enter_timestamp_label;
83 private RightLabel unit_active_exit_timestamp_label;
84 private RightLabel unit_can_start_label;
85 private RightLabel unit_can_reload_label;
86 private RightLabel unit_cgroup_label;
87
88 private RightLabel job_id_label;
89 private RightLabel job_state_label;
90 private RightLabel job_type_label;
91
92 private ComboBox unit_type_combo_box;
93
94 public MainWindow() throws DBus.Error {
95 title = "systemdadm";
96 position = WindowPosition.CENTER;
97 set_default_size(1000, 700);
98 set_border_width(12);
99 destroy += Gtk.main_quit;
100
101 Notebook notebook = new Notebook();
102 add(notebook);
103
104 Box unit_vbox = new VBox(false, 12);
105 notebook.append_page(unit_vbox, new Label("Units"));
106 unit_vbox.set_border_width(12);
107
108 Box job_vbox = new VBox(false, 12);
109 notebook.append_page(job_vbox, new Label("Jobs"));
110 job_vbox.set_border_width(12);
111
112 unit_type_combo_box = new ComboBox.text();
113 Box type_hbox = new HBox(false, 6);
114 type_hbox.pack_start(unit_type_combo_box, false, false, 0);
115 unit_vbox.pack_start(type_hbox, false, false, 0);
116
117 unit_type_combo_box.append_text("Show All Units");
118 unit_type_combo_box.append_text("Show Only Live Units");
119 unit_type_combo_box.append_text("Services");
120 unit_type_combo_box.append_text("Sockets");
121 unit_type_combo_box.append_text("Devices");
122 unit_type_combo_box.append_text("Mounts");
123 unit_type_combo_box.append_text("Automounts");
124 unit_type_combo_box.append_text("Targets");
125 unit_type_combo_box.append_text("Snapshots");
126 unit_type_combo_box.set_active(1);
127 unit_type_combo_box.changed += unit_type_changed;
128
129 server_snapshot_button = new Button.with_mnemonic("Take _Snapshot");
130 server_reload_button = new Button.with_mnemonic("Reload _Configuration");
131
132 server_snapshot_button.clicked += on_server_snapshot;
133 server_reload_button.clicked += on_server_reload;
134
135 type_hbox.pack_end(server_snapshot_button, false, true, 0);
136 type_hbox.pack_end(server_reload_button, false, true, 0);
137
138 unit_model = new ListStore(7, typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(Unit));
139 job_model = new ListStore(6, typeof(string), typeof(string), typeof(string), typeof(string), typeof(Job), typeof(uint32));
140
141 TreeModelFilter unit_model_filter;
142 unit_model_filter = new TreeModelFilter(unit_model, null);
143 unit_model_filter.set_visible_func(unit_filter);
144
145 unit_view = new TreeView.with_model(unit_model_filter);
146 job_view = new TreeView.with_model(job_model);
147
148 unit_view.cursor_changed += unit_changed;
149 job_view.cursor_changed += job_changed;
150
151 unit_view.insert_column_with_attributes(-1, "Load State", new CellRendererText(), "text", 2);
152 unit_view.insert_column_with_attributes(-1, "Active State", new CellRendererText(), "text", 3);
153 unit_view.insert_column_with_attributes(-1, "Unit State", new CellRendererText(), "text", 4);
154 unit_view.insert_column_with_attributes(-1, "Unit", new CellRendererText(), "text", 0);
155 unit_view.insert_column_with_attributes(-1, "Job", new CellRendererText(), "text", 5);
156
157 job_view.insert_column_with_attributes(-1, "Job", new CellRendererText(), "text", 0);
158 job_view.insert_column_with_attributes(-1, "Unit", new CellRendererText(), "text", 1);
159 job_view.insert_column_with_attributes(-1, "Type", new CellRendererText(), "text", 2);
160 job_view.insert_column_with_attributes(-1, "State", new CellRendererText(), "text", 3);
161
162 ScrolledWindow scroll = new ScrolledWindow(null, null);
163 scroll.set_policy(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC);
164 scroll.set_shadow_type(ShadowType.IN);
165 scroll.add(unit_view);
166 unit_vbox.pack_start(scroll, true, true, 0);
167
168 scroll = new ScrolledWindow(null, null);
169 scroll.set_policy(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC);
170 scroll.set_shadow_type(ShadowType.IN);
171 scroll.add(job_view);
172 job_vbox.pack_start(scroll, true, true, 0);
173
174 unit_id_label = new RightLabel();
175 unit_aliases_label = new RightLabel();
176 unit_description_label = new RightLabel();
177 unit_load_state_label = new RightLabel();
178 unit_active_state_label = new RightLabel();
179 unit_sub_state_label = new RightLabel();
180 unit_fragment_path_label = new RightLabel();
181 unit_active_enter_timestamp_label = new RightLabel();
182 unit_active_exit_timestamp_label = new RightLabel();
183 unit_can_start_label = new RightLabel();
184 unit_can_reload_label = new RightLabel();
185 unit_cgroup_label = new RightLabel();
186
187 job_id_label = new RightLabel();
188 job_state_label = new RightLabel();
189 job_type_label = new RightLabel();
190
191 Table unit_table = new Table(8, 6, false);
192 unit_table.set_row_spacings(6);
193 unit_table.set_border_width(0);
194 unit_vbox.pack_start(unit_table, false, true, 0);
195
196 Table job_table = new Table(2, 2, false);
197 job_table.set_row_spacings(6);
198 job_table.set_border_width(0);
199 job_vbox.pack_start(job_table, false, true, 0);
200
201 unit_table.attach(new LeftLabel("Id:"), 0, 1, 0, 1, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
202 unit_table.attach(unit_id_label, 1, 5, 0, 1, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
203 unit_table.attach(new LeftLabel("Aliases:"), 0, 1, 1, 2, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
204 unit_table.attach(unit_aliases_label, 1, 5, 1, 2, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
205 unit_table.attach(new LeftLabel("Description:"), 0, 1, 2, 3, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
206 unit_table.attach(unit_description_label, 1, 5, 2, 3, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
207 unit_table.attach(new LeftLabel("Fragment Path:"), 0, 1, 3, 4, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
208 unit_table.attach(unit_fragment_path_label, 1, 5, 3, 4, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
209 unit_table.attach(new LeftLabel("Control Group:"), 0, 1, 4, 5, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
210 unit_table.attach(unit_cgroup_label, 1, 5, 4, 5, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
211
212 unit_table.attach(new LeftLabel("Load State:"), 0, 1, 5, 6, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
213 unit_table.attach(unit_load_state_label, 1, 2, 5, 6, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
214 unit_table.attach(new LeftLabel("Active State:"), 0, 1, 6, 7, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
215 unit_table.attach(unit_active_state_label, 1, 2, 6, 7, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
216 unit_table.attach(new LeftLabel("Unit State:"), 0, 1, 7, 8, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
217 unit_table.attach(unit_sub_state_label, 1, 2, 7, 8, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
218
219 unit_table.attach(new LeftLabel("Active Enter Timestamp:"), 2, 3, 6, 7, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
220 unit_table.attach(unit_active_enter_timestamp_label, 3, 4, 6, 7, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
221 unit_table.attach(new LeftLabel("Active Exit Timestamp:"), 2, 3, 7, 8, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
222 unit_table.attach(unit_active_exit_timestamp_label, 3, 4, 7, 8, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
223
224 unit_table.attach(new LeftLabel("Can Start/Stop:"), 4, 5, 6, 7, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
225 unit_table.attach(unit_can_start_label, 5, 6, 6, 7, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
226 unit_table.attach(new LeftLabel("Can Reload:"), 4, 5, 7, 8, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
227 unit_table.attach(unit_can_reload_label, 5, 6, 7, 8, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
228
229 job_table.attach(new LeftLabel("Id:"), 0, 1, 0, 1, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
230 job_table.attach(job_id_label, 1, 2, 0, 1, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
231 job_table.attach(new LeftLabel("State:"), 0, 1, 1, 2, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
232 job_table.attach(job_state_label, 1, 2, 1, 2, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
233 job_table.attach(new LeftLabel("Type:"), 0, 1, 2, 3, AttachOptions.FILL, AttachOptions.FILL, 0, 0);
234 job_table.attach(job_type_label, 1, 2, 2, 3, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0);
235
236 ButtonBox bbox = new HButtonBox();
237 bbox.set_layout(ButtonBoxStyle.START);
238 bbox.set_spacing(6);
239 unit_vbox.pack_start(bbox, false, true, 0);
240
241 start_button = new Button.with_mnemonic("_Start");
242 stop_button = new Button.with_mnemonic("Sto_p");
243 reload_button = new Button.with_mnemonic("_Reload");
244 restart_button = new Button.with_mnemonic("Res_tart");
245
246 start_button.clicked += on_start;
247 stop_button.clicked += on_stop;
248 reload_button.clicked += on_reload;
249 restart_button.clicked += on_restart;
250
251 bbox.pack_start(start_button, false, true, 0);
252 bbox.pack_start(stop_button, false, true, 0);
253 bbox.pack_start(restart_button, false, true, 0);
254 bbox.pack_start(reload_button, false, true, 0);
255
256 bbox = new HButtonBox();
257 bbox.set_layout(ButtonBoxStyle.START);
258 bbox.set_spacing(6);
259 job_vbox.pack_start(bbox, false, true, 0);
260
261 cancel_button = new Button.with_mnemonic("_Cancel");
262
263 cancel_button.clicked += on_cancel;
264
265 bbox.pack_start(cancel_button, false, true, 0);
266
267 bus = Bus.get(session ? BusType.SESSION : BusType.SYSTEM);
268
269 manager = bus.get_object(
270 "org.freedesktop.systemd1",
271 "/org/freedesktop/systemd1",
272 "org.freedesktop.systemd1.Manager") as Manager;
273
274 manager.unit_new += on_unit_new;
275 manager.job_new += on_job_new;
276 manager.unit_removed += on_unit_removed;
277 manager.job_removed += on_job_removed;
278
279 manager.subscribe();
280
281 clear_unit();
282 clear_job();
283 populate_unit_model();
284 populate_job_model();
285 }
286
287 public void populate_unit_model() throws DBus.Error {
288 unit_model.clear();
289
290 var list = manager.list_units();
291
292 foreach (var i in list) {
293 TreeIter iter;
294
295 Unit u = bus.get_object(
296 "org.freedesktop.systemd1",
297 i.unit_path,
298 "org.freedesktop.systemd1.Unit") as Unit;
299
300 unit_model.append(out iter);
301 unit_model.set(iter,
302 0, i.id,
303 1, i.description,
304 2, i.load_state,
305 3, i.active_state,
306 4, i.sub_state,
307 5, i.job_type != "" ? "→ %s".printf(i.job_type) : "",
308 6, u);
309 }
310 }
311
312 public void populate_job_model() throws DBus.Error {
313 job_model.clear();
314
315 var list = manager.list_jobs();
316
317 foreach (var i in list) {
318 TreeIter iter;
319
320 Job j = bus.get_object(
321 "org.freedesktop.systemd1",
322 i.job_path,
323 "org.freedesktop.systemd1.Job") as Job;
324
325 job_model.append(out iter);
326 job_model.set(iter,
327 0, "%u".printf(i.id),
328 1, i.name,
329 2, "→ %s".printf(i.type),
330 3, i.state,
331 4, j,
332 5, i.id);
333 }
334 }
335
336 public Unit? get_current_unit() {
337 TreePath p;
338 unit_view.get_cursor(out p, null);
339
340 if (p == null)
341 return null;
342
343 TreeModel model = unit_view.get_model();
344 TreeIter iter;
345 Unit u;
346
347 model.get_iter(out iter, p);
348 model.get(iter, 6, out u);
349
350 return u;
351 }
352
353 public void unit_changed() {
354 Unit u = get_current_unit();
355
356 if (u == null)
357 clear_unit();
358 else
359 show_unit(u);
360 }
361
362 public void clear_unit() {
363 current_unit_id = null;
364
365 start_button.set_sensitive(false);
366 stop_button.set_sensitive(false);
367 reload_button.set_sensitive(false);
368 restart_button.set_sensitive(false);
369
370 unit_id_label.set_text_or_na();
371 unit_aliases_label.set_text_or_na();
372 unit_description_label.set_text_or_na();
373 unit_load_state_label.set_text_or_na();
374 unit_active_state_label.set_text_or_na();
375 unit_sub_state_label.set_text_or_na();
376 unit_fragment_path_label.set_text_or_na();
377 unit_active_enter_timestamp_label.set_text_or_na();
378 unit_active_exit_timestamp_label.set_text_or_na();
379 unit_can_reload_label.set_text_or_na();
380 unit_can_start_label.set_text_or_na();
381 unit_cgroup_label.set_text_or_na();
382 }
383
384 public void show_unit(Unit unit) {
385 current_unit_id = unit.id;
386
387 unit_id_label.set_text_or_na(current_unit_id);
388 unit_aliases_label.set_text_or_na(string.joinv("\n", unit.names));
389
390 unit_description_label.set_text_or_na(unit.description);
391 unit_load_state_label.set_text_or_na(unit.load_state);
392 unit_active_state_label.set_text_or_na(unit.active_state);
393 unit_sub_state_label.set_text_or_na(unit.sub_state);
394 unit_fragment_path_label.set_text_or_na(unit.fragment_path);
395
396 uint64 t = unit.active_enter_timestamp;
397 if (t > 0) {
398 TimeVal tv = { (long) (t / 1000000), (long) (t % 1000000) };
399 unit_active_enter_timestamp_label.set_text_or_na(tv.to_iso8601());
400 } else
401 unit_active_enter_timestamp_label.set_text_or_na();
402
403 t = unit.active_exit_timestamp;
404 if (t > 0) {
405 TimeVal tv = { (long) (t / 1000000), (long) (t % 1000000) };
406 unit_active_exit_timestamp_label.set_text_or_na(tv.to_iso8601());
407 } else
408 unit_active_exit_timestamp_label.set_text_or_na();
409
410 bool b = unit.can_start;
411 start_button.set_sensitive(b);
412 stop_button.set_sensitive(b);
413 restart_button.set_sensitive(b);
414 unit_can_start_label.set_text_or_na(b ? "Yes" : "No");
415
416 b = unit.can_reload;
417 reload_button.set_sensitive(b);
418 unit_can_reload_label.set_text_or_na(b ? "Yes" : "No");
419
420 unit_cgroup_label.set_text_or_na(unit.default_control_group);
421 }
422
423 public Job? get_current_job() {
424 TreePath p;
425 job_view.get_cursor(out p, null);
426
427 if (p == null)
428 return null;
429
430 TreeIter iter;
431 TreeModel model = job_view.get_model();
432 Job *j;
433
434 model.get_iter(out iter, p);
435 model.get(iter, 4, out j);
436
437 return j;
438 }
439
440 public void job_changed() {
441 Job j = get_current_job();
442
443 if (j == null)
444 clear_job();
445 else
446 show_job(j);
447 }
448
449 public void clear_job() {
450 current_job_id = 0;
451
452 job_id_label.set_text_or_na();
453 job_state_label.set_text_or_na();
454 job_type_label.set_text_or_na();
455
456 cancel_button.set_sensitive(false);
457 }
458
459 public void show_job(Job job) {
460 current_job_id = job.id;
461
462 job_id_label.set_text_or_na("%u".printf(current_job_id));
463 job_state_label.set_text_or_na(job.state);
464 job_type_label.set_text_or_na(job.job_type);
465
466 cancel_button.set_sensitive(true);
467 }
468
469 public void on_start() {
470 Unit u = get_current_unit();
471
472 if (u == null)
473 return;
474
475 try {
476 u.start("replace");
477 } catch (DBus.Error e) {
478 message("%s", e.message);
479 }
480 }
481
482 public void on_stop() {
483 Unit u = get_current_unit();
484
485 if (u == null)
486 return;
487
488 try {
489 u.stop("replace");
490 } catch (DBus.Error e) {
491 message("%s", e.message);
492 }
493 }
494
495 public void on_reload() {
496 Unit u = get_current_unit();
497
498 if (u == null)
499 return;
500
501 try {
502 u.reload("replace");
503 } catch (DBus.Error e) {
504 message("%s", e.message);
505 }
506 }
507
508 public void on_restart() {
509 Unit u = get_current_unit();
510
511 if (u == null)
512 return;
513
514 try {
515 u.restart("replace");
516 } catch (DBus.Error e) {
517 message("%s", e.message);
518 }
519 }
520
521 public void on_cancel() {
522 Job j = get_current_job();
523
524 if (j == null)
525 return;
526
527 try {
528 j.cancel();
529 } catch (DBus.Error e) {
530 message("%s", e.message);
531 }
532 }
533
534 public void on_unit_new(string id, ObjectPath path) {
535 Unit u = bus.get_object(
536 "org.freedesktop.systemd1",
537 path,
538 "org.freedesktop.systemd1.Unit") as Unit;
539
540 string t = "";
541 Unit.JobLink jl = u.job;
542
543 if (jl.id != 0) {
544 Job j = bus.get_object(
545 "org.freedesktop.systemd1",
546 jl.path,
547 "org.freedesktop.systemd1.Job") as Job;
548
549 t = j.job_type;
550 }
551
552 TreeIter iter;
553 unit_model.append(out iter);
554 unit_model.set(iter,
555 0, id,
556 1, u.description,
557 2, u.load_state,
558 3, u.active_state,
559 4, u.sub_state,
560 5, t != "" ? "→ %s".printf(t) : "",
561 6, u);
562 }
563
564 public void on_job_new(uint32 id, ObjectPath path) {
565 Job j = bus.get_object(
566 "org.freedesktop.systemd1",
567 path,
568 "org.freedesktop.systemd1.Job") as Job;
569
570 TreeIter iter;
571 job_model.append(out iter);
572 job_model.set(iter,
573 0, "%u".printf(j.id),
574 1, j.unit.id,
575 2, "→ %s".printf(j.job_type),
576 3, j.state,
577 4, j,
578 5, id);
579 }
580
581 public void on_unit_removed(string id, ObjectPath path) {
582 TreeIter iter;
583 if (!(unit_model.get_iter_first(out iter)))
584 return;
585
586 do {
587 string name;
588
589 unit_model.get(iter, 0, out name);
590
591 if (id == name) {
592 if (current_unit_id == name)
593 clear_unit();
594
595 unit_model.remove(iter);
596 break;
597 }
598
599 } while (unit_model.iter_next(ref iter));
600 }
601
602 public void on_job_removed(uint32 id, ObjectPath path) {
603 TreeIter iter;
604 if (!(job_model.get_iter_first(out iter)))
605 return;
606
607 do {
608 uint32 j;
609
610 job_model.get(iter, 5, out j);
611
612 if (id == j) {
613 if (current_job_id == j)
614 clear_job();
615
616 job_model.remove(iter);
617
618 break;
619 }
620
621 } while (job_model.iter_next(ref iter));
622 }
623
624 public bool unit_filter(TreeModel model, TreeIter iter) {
625 string id, active_state;
626
627 model.get(iter, 0, out id, 3, out active_state);
628
629 if (id == null)
630 return false;
631
632 switch (unit_type_combo_box.get_active()) {
633
634 case 0:
635 return true;
636
637 case 1:
638 return active_state != "inactive";
639
640 case 2:
641 return id.has_suffix(".service");
642
643 case 3:
644 return id.has_suffix(".socket");
645
646 case 4:
647 return id.has_suffix(".device");
648
649 case 5:
650 return id.has_suffix(".mount");
651
652 case 6:
653 return id.has_suffix(".automount");
654
655 case 7:
656 return id.has_suffix(".target");
657
658 case 8:
659 return id.has_suffix(".snapshot");
660 }
661
662 return false;
663 }
664
665 public void unit_type_changed() {
666 TreeModelFilter model = (TreeModelFilter) unit_view.get_model();
667
668 model.refilter();
669 }
670
671 public void on_server_reload() {
672 try {
673 manager.reload();
674 } catch (DBus.Error e) {
675 message("%s", e.message);
676 }
677 }
678
679 public void on_server_snapshot() {
680 try {
681 manager.create_snapshot();
682
683 if (unit_type_combo_box.get_active() != 0)
684 unit_type_combo_box.set_active(8);
685
686 } catch (DBus.Error e) {
687 message("%s", e.message);
688 }
689 }
690 }
691
692 static const OptionEntry entries[] = {
693 { "session", 0, 0, OptionArg.NONE, out session, "Connect to session bus", null },
694 { "system", 0, OptionFlags.REVERSE, OptionArg.NONE, out session, "Connect to system bus", null },
695 { null }
696 };
697
698 int main (string[] args) {
699
700 try {
701 Gtk.init_with_args(ref args, "[OPTION...]", entries, "systemadm");
702
703 MainWindow window = new MainWindow();
704 window.show_all();
705
706 Gtk.main();
707 } catch (DBus.Error e) {
708 message("%s", e.message);
709 } catch (GLib.Error e) {
710 message("%s", e.message);
711 }
712
713 return 0;
714 }