applet: print strerror and exit if execlp() fails
[espeaktime] / src / applet.c
index 0ca518a..9659081 100644 (file)
@@ -1,4 +1,5 @@
 #include <unistd.h>
 #include <unistd.h>
+#include <errno.h>
 #include <gtk/gtk.h>
 #include <hildon/hildon.h>
 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
 #include <gtk/gtk.h>
 #include <hildon/hildon.h>
 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
@@ -126,7 +127,7 @@ static void cfg_free(struct espeaktime_settings *cfg)
        g_free(cfg->text);
 }
 
        g_free(cfg->text);
 }
 
-static void do_test(struct espeaktime_settings *cfg)
+static void cfg_speak(struct espeaktime_settings *cfg, gboolean test_mode)
 {
        gchar astr[16], pstr[16], sstr[16];
        gchar vstr[64];
 {
        gchar astr[16], pstr[16], sstr[16];
        gchar vstr[64];
@@ -158,7 +159,8 @@ static void do_test(struct espeaktime_settings *cfg)
        res = execlp(ESPEAK_BIN, ESPEAK_BIN,
                "-a", astr, "-p", pstr, "-s", sstr, "-v", vstr,
                text, NULL);
        res = execlp(ESPEAK_BIN, ESPEAK_BIN,
                "-a", astr, "-p", pstr, "-s", sstr, "-v", vstr,
                text, NULL);
-       g_print("execlp: %d\n", res);
+       g_print("execlp: %d (%s)\n", res, g_strerror(errno));
+       exit(res);
 }
 
 
 }
 
 
@@ -274,7 +276,7 @@ osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activat
                switch (result) {
                case 1:
                        g_print("Test button\n");
                switch (result) {
                case 1:
                        g_print("Test button\n");
-                       do_test(&cfg);
+                       cfg_speak(&cfg, TRUE);
                        continue;
                case GTK_RESPONSE_OK:
                        g_print("Save\n");
                        continue;
                case GTK_RESPONSE_OK:
                        g_print("Save\n");