aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2021-01-24 03:38:44 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-01-27 17:10:40 +0100
commitb85daf94830a3ca39d59237fdb07bc33ede1c450 (patch)
tree8d704b1d8614759da71fbe42dca737c0e2261142 /src/main.c
parent9b8fb0492c8c05630644d840aef520f3c6b17829 (diff)
downloadayatana-indicator-keyboard-b85daf94830a3ca39d59237fdb07bc33ede1c450.tar.gz
ayatana-indicator-keyboard-b85daf94830a3ca39d59237fdb07bc33ede1c450.tar.bz2
ayatana-indicator-keyboard-b85daf94830a3ca39d59237fdb07bc33ede1c450.zip
100% re-write of the keyboard indicator in plain C.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 00000000..eb6a1b9a
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,40 @@
+#include <locale.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-unix.h>
+#include "service.h"
+
+static void onNameLost(gpointer instance G_GNUC_UNUSED, gpointer pLoop)
+{
+ g_message("exiting: service couldn't acquire or lost ownership of busname");
+ g_main_loop_quit((GMainLoop*)pLoop);
+}
+
+static gboolean onQuit(gpointer pData)
+{
+ GMainLoop *pLoop = (GMainLoop*)pData;
+ g_main_loop_quit(pLoop);
+
+ return G_SOURCE_REMOVE;
+}
+
+int main(int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
+{
+ setlocale(LC_ALL, "");
+ bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
+ textdomain(GETTEXT_PACKAGE);
+
+ IndicatorKeyboardService *pService = indicator_keyboard_service_new(NULL);
+ GMainLoop *pLoop = g_main_loop_new(NULL, FALSE);
+
+ g_signal_connect(pService, "name-lost", G_CALLBACK(onNameLost), pLoop);
+ g_unix_signal_add(SIGINT, onQuit, pLoop);
+
+ indicator_keyboard_service_AddKeyboardSource(pService);
+
+ g_main_loop_run(pLoop);
+ g_main_loop_unref(pLoop);
+ g_clear_object(&pService);
+
+ return 0;
+}