Blob Blame History Raw
From ba301f8dd803bbcb6d2923e54e4bc465931babbb Mon Sep 17 00:00:00 2001
From: Patrick Monnerat <patrick@monnerat.net>
Date: Sun, 2 Jul 2017 16:34:11 +0100
Subject: [PATCH] mouse: warn about enabling multi-finger emulation

libinput disables software buttons when clickfinger is enabled.
---
 capplets/mouse/mate-mouse-properties.c  | 29 ++++++++++++++++++++++++-----
 capplets/mouse/mate-mouse-properties.ui | 19 +++++++++++++++++++
 2 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/capplets/mouse/mate-mouse-properties.c b/capplets/mouse/mate-mouse-properties.c
index 5d8b5ee..d8ed198 100644
--- a/capplets/mouse/mate-mouse-properties.c
+++ b/capplets/mouse/mate-mouse-properties.c
@@ -219,11 +219,30 @@ synaptics_check_capabilities (GtkBuilder *dialog)
 }
 
 static void
-comboxbox_changed_callback (GtkWidget *combobox, void *data)
+comboxbox_changed (GtkWidget *combobox, GtkBuilder *dialog, const char *key)
 {
 	gint value = gtk_combo_box_get_active (GTK_COMBO_BOX (combobox));
-	gchar *key = (char *) data;
-	g_settings_set_int (touchpad_settings, key, value);
+	gint value2, value3;
+	GtkLabel *warn = GTK_LABEL (WID ("multi_finger_warning"));
+
+	g_settings_set_int (touchpad_settings, (const gchar *) key, value);
+
+	/* Show warning if some multi-finger click emulation is enabled. */
+	value2 = g_settings_get_int (touchpad_settings, "two-finger-click");
+	value3 = g_settings_get_int (touchpad_settings, "three-finger-click");
+	gtk_widget_set_opacity (warn, (value2 || value3)?  1.0: 0.0);
+}
+
+static void
+comboxbox_two_finger_changed_callback (GtkWidget *combobox, void *data)
+{
+	comboxbox_changed (combobox, GTK_BUILDER (data), "two-finger-click");
+}
+
+static void
+comboxbox_three_finger_changed_callback (GtkWidget *combobox, void *data)
+{
+	comboxbox_changed (combobox, GTK_BUILDER (data), "three-finger-click");
 }
 
 /* Set up the property editors in the dialog. */
@@ -311,12 +330,12 @@ setup_dialog (GtkBuilder *dialog)
 			gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (three_click_comboxbox), emulation_values[i]);	
 		}
 		
+		g_signal_connect (two_click_comboxbox, "changed", G_CALLBACK (comboxbox_two_finger_changed_callback), dialog);
+		g_signal_connect (three_click_comboxbox, "changed", G_CALLBACK (comboxbox_three_finger_changed_callback), dialog);
 		gtk_combo_box_set_active (GTK_COMBO_BOX (two_click_comboxbox), g_settings_get_int (touchpad_settings, "two-finger-click"));
 		gtk_combo_box_set_active (GTK_COMBO_BOX (three_click_comboxbox), g_settings_get_int (touchpad_settings, "three-finger-click"));
 		gtk_widget_show (two_click_comboxbox);
 		gtk_widget_show (three_click_comboxbox);
-		g_signal_connect (two_click_comboxbox, "changed", G_CALLBACK (comboxbox_changed_callback), "two-finger-click");
-		g_signal_connect (three_click_comboxbox, "changed", G_CALLBACK (comboxbox_changed_callback), "three-finger-click");
 
 		/* speed */
 		g_settings_bind (touchpad_settings, "motion-acceleration",
diff --git a/capplets/mouse/mate-mouse-properties.ui b/capplets/mouse/mate-mouse-properties.ui
index a1f068a..79214d1 100644
--- a/capplets/mouse/mate-mouse-properties.ui
+++ b/capplets/mouse/mate-mouse-properties.ui
@@ -1008,6 +1008,25 @@
                         <property name="position">3</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkLabel" id="multi_finger_warning">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">start</property>
+                        <property name="margin_left">12</property>
+                        <property name="margin_top">5</property>
+                        <property name="hexpand">True</property>
+                        <property name="label" translatable="yes">Warning: multi-finger emulation may disable software buttons</property>
+                        <attributes>
+                          <attribute name="style" value="italic"/>
+                        </attributes>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">4</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
-- 
2.13.0