summaryrefslogtreecommitdiff
path: root/systemadm.vala
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-04-24 03:37:42 +0200
committerLennart Poettering <lennart@poettering.net>2010-04-24 03:37:42 +0200
commite6be8af492e8db1cd5e23595554b6c642f1b8138 (patch)
treed965ceafe4acf08a7eed3dff1df38c7fa1059590 /systemadm.vala
parent22be7e82e20a972b0e2338ee9af11a79033a8db4 (diff)
systemadm: destroy error dialog boxes properly
Diffstat (limited to 'systemadm.vala')
-rw-r--r--systemadm.vala34
1 files changed, 25 insertions, 9 deletions
diff --git a/systemadm.vala b/systemadm.vala
index bdff0d4259..fdc84648dc 100644
--- a/systemadm.vala
+++ b/systemadm.vala
@@ -486,7 +486,7 @@ public class MainWindow : Window {
try {
u.start("replace");
} catch (DBus.Error e) {
- new MessageDialog(this, DialogFlags.DESTROY_WITH_PARENT, MessageType.ERROR, ButtonsType.CLOSE, "%s", e.message).run();
+ show_error(e.message);
}
}
@@ -499,7 +499,7 @@ public class MainWindow : Window {
try {
u.stop("replace");
} catch (DBus.Error e) {
- new MessageDialog(this, DialogFlags.DESTROY_WITH_PARENT, MessageType.ERROR, ButtonsType.CLOSE, "%s", e.message).run();
+ show_error(e.message);
}
}
@@ -512,7 +512,7 @@ public class MainWindow : Window {
try {
u.reload("replace");
} catch (DBus.Error e) {
- new MessageDialog(this, DialogFlags.DESTROY_WITH_PARENT, MessageType.ERROR, ButtonsType.CLOSE, "%s", e.message).run();
+ show_error(e.message);
}
}
@@ -525,7 +525,7 @@ public class MainWindow : Window {
try {
u.restart("replace");
} catch (DBus.Error e) {
- new MessageDialog(this, DialogFlags.DESTROY_WITH_PARENT, MessageType.ERROR, ButtonsType.CLOSE, "%s", e.message).run();
+ show_error(e.message);
}
}
@@ -538,7 +538,7 @@ public class MainWindow : Window {
try {
j.cancel();
} catch (DBus.Error e) {
- new MessageDialog(this, DialogFlags.DESTROY_WITH_PARENT, MessageType.ERROR, ButtonsType.CLOSE, "%s", e.message).run();
+ show_error(e.message);
}
}
@@ -683,7 +683,7 @@ public class MainWindow : Window {
try {
manager.reload();
} catch (DBus.Error e) {
- new MessageDialog(this, DialogFlags.DESTROY_WITH_PARENT, MessageType.ERROR, ButtonsType.CLOSE, "%s", e.message).run();
+ show_error(e.message);
}
}
@@ -695,9 +695,19 @@ public class MainWindow : Window {
unit_type_combo_box.set_active(8);
} catch (DBus.Error e) {
- new MessageDialog(this, DialogFlags.DESTROY_WITH_PARENT, MessageType.ERROR, ButtonsType.CLOSE, "%s", e.message).run();
+ show_error(e.message);
}
}
+
+ public void show_error(string e) {
+ var m = new MessageDialog(this,
+ DialogFlags.DESTROY_WITH_PARENT,
+ MessageType.ERROR,
+ ButtonsType.CLOSE, "%s", e);
+ m.run();
+ m.destroy();
+ }
+
}
static const OptionEntry entries[] = {
@@ -706,6 +716,12 @@ static const OptionEntry entries[] = {
{ null }
};
+void show_error(string e) {
+ var m = new MessageDialog(null, 0, MessageType.ERROR, ButtonsType.CLOSE, "%s", e);
+ m.run();
+ m.destroy();
+}
+
int main (string[] args) {
try {
@@ -716,9 +732,9 @@ int main (string[] args) {
Gtk.main();
} catch (DBus.Error e) {
- new MessageDialog(null, 0, MessageType.ERROR, ButtonsType.CLOSE, "%s", e.message).run();
+ show_error(e.message);
} catch (GLib.Error e) {
- new MessageDialog(null, 0, MessageType.ERROR, ButtonsType.CLOSE, "%s", e.message).run();
+ show_error(e.message);
}
return 0;