aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-08-22 13:38:48 +0000
committerTarmac <Unknown>2013-08-22 13:38:48 +0000
commit05cd692f9117c79cbfe4d4a31c1303e0e9e4d878 (patch)
treeec06eaa20e957c473b9a6e26ae03d3457d4932c6
parente974f427722c25b3bcc1bd90c4c32465f6ca135d (diff)
parent201e48e1b010ebf180034abb8d61cafaba8a08a0 (diff)
downloadayatana-indicator-keyboard-05cd692f9117c79cbfe4d4a31c1303e0e9e4d878.tar.gz
ayatana-indicator-keyboard-05cd692f9117c79cbfe4d4a31c1303e0e9e4d878.tar.bz2
ayatana-indicator-keyboard-05cd692f9117c79cbfe4d4a31c1303e0e9e4d878.zip
Proper shutdown on SIGTERM.
Approved by Ted Gould, PS Jenkins bot.
-rw-r--r--lib/main.vala32
-rw-r--r--po/indicator-keyboard.pot8
2 files changed, 30 insertions, 10 deletions
diff --git a/lib/main.vala b/lib/main.vala
index 601a599e..83e31dc0 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -19,6 +19,7 @@
[DBus (name = "com.canonical.indicator.keyboard")]
public class Indicator.Keyboard.Service : Object {
+ private static Service service;
private static IBus.Bus? ibus;
private bool force;
@@ -83,6 +84,22 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
+ public void up () {
+ if (loop == null) {
+ loop = new MainLoop ();
+ ((!) loop).run ();
+ }
+ }
+
+ [DBus (visible = false)]
+ public void down () {
+ if (loop != null) {
+ ((!) loop).quit ();
+ loop = null;
+ }
+ }
+
+ [DBus (visible = false)]
private void acquire_bus_name () {
Bus.own_name (BusType.SESSION,
"com.canonical.indicator.keyboard",
@@ -90,9 +107,6 @@ public class Indicator.Keyboard.Service : Object {
handle_bus_acquired,
null,
handle_name_lost);
-
- loop = new MainLoop ();
- ((!) loop).run ();
}
[DBus (visible = false)]
@@ -551,13 +565,19 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
private void handle_name_lost (DBusConnection? connection, string name) {
- ((!) loop).quit ();
- loop = null;
+ down ();
}
[DBus (visible = false)]
public static int main (string[] args) {
- new Service (ref args);
+ Service.service = new Service (ref args);
+
+ Posix.signal (Posix.SIGTERM, (code) => {
+ Service.service.down ();
+ });
+
+ Service.service.up ();
+
return 0;
}
}
diff --git a/po/indicator-keyboard.pot b/po/indicator-keyboard.pot
index b657f08e..3cbc4c2e 100644
--- a/po/indicator-keyboard.pot
+++ b/po/indicator-keyboard.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-08-21 12:15+0800\n"
+"POT-Creation-Date: 2013-08-22 15:09+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,14 +17,14 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: ../lib/main.c:1419 ../lib/main.vala:328
+#: ../lib/main.c:1449 ../lib/main.vala:342
msgid "Character Map"
msgstr ""
-#: ../lib/main.c:1421 ../lib/main.vala:329
+#: ../lib/main.c:1451 ../lib/main.vala:343
msgid "Keyboard Layout Chart"
msgstr ""
-#: ../lib/main.c:1423 ../lib/main.vala:330
+#: ../lib/main.c:1453 ../lib/main.vala:344
msgid "Text Entry Settings..."
msgstr ""