Add configuration flag to skip warning about input fallback mode.
authorAlexander Koenig <alex@lisas.de>
Fri, 17 Jun 2016 21:33:35 +0000 (23:33 +0200)
committerAlexander Koenig <alex@lisas.de>
Fri, 17 Jun 2016 21:33:35 +0000 (23:33 +0200)
src/main.cc
src/tX_global.c
src/tX_global.h

index 1cae9715b750781d3733a2baa6002ab7e0b7a958..f57cf4ec316c9908ecc5d5faf6f456a399f1709b 100644 (file)
@@ -282,15 +282,32 @@ int main(int argc, char **argv)
                char buffer[4096];
                const char *errorFmt = "<span size=\"larger\" weight=\"bold\">Failed to access input hardware</span>\n\n"
                        "terminatorX failed to get direct access to the Linux input interface and "
-                       "will now fallback to the standard \"pointer warp\" mode, which will result in "
+                       "will now fall back to the standard \"pointer warp\" mode, which may result in "
                        "<span weight=\"bold\">significantly reduced scratching precision</span>.\n\nTo achieve "
                        "high precision scratching either\n - <span style=\"italic\">install terminatorX suid-root</span>, or\n"
                        " - <span style=\"italic\">add the users running terminatorX to a group that can access the special "
                        "file \"/dev/input/mice\"</span>\nand restart terminatorX.\n\n"
                        "The reported error was: <span weight=\"bold\">%s</span>";
 
-               snprintf(buffer, 4096, errorFmt, mouse_error->message);
-               tx_note(buffer, true, NULL);
+
+               if (globals.input_fallback_warning) {
+                       snprintf(buffer, 4096, errorFmt, mouse_error->message);
+                       GtkWidget *dialog=gtk_message_dialog_new_with_markup(GTK_WINDOW(main_window), GTK_DIALOG_DESTROY_WITH_PARENT,
+                                       GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", "");
+                       gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dialog), buffer);
+                       GtkWidget *message_area = gtk_message_dialog_get_message_area(GTK_MESSAGE_DIALOG(dialog));
+                       GtkWidget *check_button = gtk_check_button_new_with_mnemonic ("Show this warning next time");
+                       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button), 1);
+                       gtk_widget_show(check_button);
+                       gtk_box_pack_start(GTK_BOX(message_area), check_button, FALSE, FALSE, 0);
+                       gtk_widget_grab_focus(gtk_dialog_get_widget_for_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE));
+                       gtk_dialog_run(GTK_DIALOG(dialog));
+                       globals.input_fallback_warning=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button));
+                       gtk_widget_destroy(dialog);
+               } else {
+                       tX_warning("Failed t access input hardware: %s", mouse_error->message);
+               }
+
                g_error_free(mouse_error);
        }
                
index 92f4a406b87fa58b0679573a8237e9d55f7cc197..ccb4dba6510de413fc05afb1e9d0bb79e4ed6435 100644 (file)
@@ -95,6 +95,7 @@ void set_global_defaults() {
        globals.use_stdout_from_conf_file=0;
        
        globals.show_nag=1;
+       globals.input_fallback_warning=1;
        globals.prelis=1;
        
        strcpy(globals.last_fn,"");
@@ -224,6 +225,7 @@ int load_globals_xml() {
                        restore_int("tooltips", globals.tooltips);
                        restore_int("use_stdout", globals.use_stdout);
                        restore_int("show_nag", globals.show_nag);
+                       restore_int("input_fallback_warning", globals.input_fallback_warning);
                        restore_int("prelis", globals.prelis);
                        restore_string("last_fn", globals.last_fn);
                        restore_float("pitch", globals.pitch);
@@ -350,6 +352,7 @@ void store_globals() {
                store_int("use_stdout", globals.use_stdout);
                // globals.use_stdout_from_conf_file=0; What the heck is this?
                store_int("show_nag", globals.show_nag);
+               store_int("input_fallback_warning", globals.input_fallback_warning);
                store_int("prelis", globals.prelis);
                store_string("last_fn", globals.last_fn);
                store_float("pitch", globals.pitch);
index c608ce6344294db5e465c969709464584d3e81bd..bfa1652087217715706084d54c76f44d698de2e2 100644 (file)
@@ -101,6 +101,7 @@ typedef struct {
        int use_stdout_cmdline;
        int use_stdout_from_conf_file;
        int show_nag;
+       int input_fallback_warning;
        
        int prelis;