From eb57870903b080d12139fcfc7850983e1087e4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 15 Aug 2024 16:48:39 -0700 Subject: [PATCH 1/2] Set mnemonic widgets, groups --- src/Views/Gestures.vala | 108 ++++++++++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 38 deletions(-) diff --git a/src/Views/Gestures.vala b/src/Views/Gestures.vala index bb1be01f..7851fabd 100644 --- a/src/Views/Gestures.vala +++ b/src/Views/Gestures.vala @@ -29,12 +29,6 @@ public class MouseTouchpad.GesturesView : Switchboard.SettingsPage { construct { show_end_title_buttons = true; - var horizontal_swipe_header = new Granite.HeaderLabel (_("Swipe Horizontally")); - - var three_swipe_horizontal_label = new Gtk.Label (_("Three fingers:")) { - halign = Gtk.Align.END - }; - var three_swipe_horizontal_combo = new Gtk.ComboBoxText () { hexpand = true }; @@ -43,8 +37,9 @@ public class MouseTouchpad.GesturesView : Switchboard.SettingsPage { three_swipe_horizontal_combo.append ("move-to-workspace", _("Move active window to workspace")); three_swipe_horizontal_combo.append ("switch-windows", _("Cycle windows")); - var four_swipe_horizontal_label = new Gtk.Label (_("Four fingers:")) { - halign = Gtk.Align.END + var three_swipe_horizontal_label = new Gtk.Label (_("Three fingers:")) { + halign = END, + mnemonic_widget = three_swipe_horizontal_combo }; var four_swipe_horizontal_combo = new Gtk.ComboBoxText (); @@ -53,65 +48,102 @@ public class MouseTouchpad.GesturesView : Switchboard.SettingsPage { four_swipe_horizontal_combo.append ("move-to-workspace", _("Move active window to workspace")); four_swipe_horizontal_combo.append ("switch-windows", _("Cycle windows")); - var swipe_up_header = new Granite.HeaderLabel (_("Swipe Up")) { - margin_top = 12 + var four_swipe_horizontal_label = new Gtk.Label (_("Four fingers:")) { + halign = END, + mnemonic_widget = four_swipe_horizontal_combo }; - var three_swipe_up_label = new Gtk.Label (_("Three fingers:")) { - halign = Gtk.Align.END + var horizontal_swipe_grid = new Gtk.Grid () { + accessible_role = GROUP, + column_spacing = 6, + row_spacing = 12 }; + horizontal_swipe_grid.attach (three_swipe_horizontal_label, 0, 1); + horizontal_swipe_grid.attach (three_swipe_horizontal_combo, 1, 1); + horizontal_swipe_grid.attach (four_swipe_horizontal_label, 0, 2); + horizontal_swipe_grid.attach (four_swipe_horizontal_combo, 1, 2); - var three_swipe_up_combo = new Gtk.ComboBoxText (); + var horizontal_swipe_header = new Granite.HeaderLabel (_("Swipe Horizontally")) { + mnemonic_widget = horizontal_swipe_grid + }; + + var three_swipe_up_combo = new Gtk.ComboBoxText () { + hexpand = true + }; three_swipe_up_combo.append ("none", _("Do nothing")); three_swipe_up_combo.append ("multitasking-view", _("Multitasking View")); - var four_swipe_up_label = new Gtk.Label (_("Four fingers:")) { - halign = Gtk.Align.END + var three_swipe_up_label = new Gtk.Label (_("Three fingers:")) { + halign = END, + mnemonic_widget = three_swipe_up_combo }; var four_swipe_up_combo = new Gtk.ComboBoxText (); four_swipe_up_combo.append ("none", _("Do nothing")); four_swipe_up_combo.append ("multitasking-view", _("Multitasking View")); - var pinch_header = new Granite.HeaderLabel (_("Pinch")) { - margin_top = 12 + var four_swipe_up_label = new Gtk.Label (_("Four fingers:")) { + halign = END, + mnemonic_widget = four_swipe_up_combo }; - var three_pinch_label = new Gtk.Label (_("Three fingers:")) { - halign = Gtk.Align.END + var swipe_up_grid = new Gtk.Grid () { + accessible_role = GROUP, + column_spacing = 6, + row_spacing = 12 }; + swipe_up_grid.attach (three_swipe_up_label, 0, 4); + swipe_up_grid.attach (three_swipe_up_combo, 1, 4); + swipe_up_grid.attach (four_swipe_up_label, 0, 5); + swipe_up_grid.attach (four_swipe_up_combo, 1, 5); - var three_pinch_combo = new Gtk.ComboBoxText (); + var swipe_up_header = new Granite.HeaderLabel (_("Swipe Up")) { + margin_top = 12, + mnemonic_widget = swipe_up_grid + }; + + var three_pinch_combo = new Gtk.ComboBoxText () { + hexpand = true + }; three_pinch_combo.append ("none", _("Do nothing")); three_pinch_combo.append ("zoom", _("Zoom")); - var four_pinch_label = new Gtk.Label (_("Four fingers:")) { - halign = Gtk.Align.END + var three_pinch_label = new Gtk.Label (_("Three fingers:")) { + halign = END, + mnemonic_widget = three_pinch_combo }; var four_pinch_combo = new Gtk.ComboBoxText (); four_pinch_combo.append ("none", _("Do nothing")); four_pinch_combo.append ("zoom", _("Zoom")); - var content_area = new Gtk.Grid () { + var four_pinch_label = new Gtk.Label (_("Four fingers:")) { + halign = END, + mnemonic_widget = four_pinch_combo + }; + + var pinch_grid = new Gtk.Grid () { + accessible_role = GROUP, column_spacing = 6, row_spacing = 12 }; - content_area.attach (horizontal_swipe_header, 0, 0, 2); - content_area.attach (three_swipe_horizontal_label, 0, 1); - content_area.attach (three_swipe_horizontal_combo, 1, 1); - content_area.attach (four_swipe_horizontal_label, 0, 2); - content_area.attach (four_swipe_horizontal_combo, 1, 2); - content_area.attach (swipe_up_header, 0, 3, 2); - content_area.attach (three_swipe_up_label, 0, 4); - content_area.attach (three_swipe_up_combo, 1, 4); - content_area.attach (four_swipe_up_label, 0, 5); - content_area.attach (four_swipe_up_combo, 1, 5); - content_area.attach (pinch_header, 0, 6, 2); - content_area.attach (three_pinch_label, 0, 7); - content_area.attach (three_pinch_combo, 1, 7); - content_area.attach (four_pinch_label, 0, 8); - content_area.attach (four_pinch_combo, 1, 8); + pinch_grid.attach (three_pinch_label, 0, 7); + pinch_grid.attach (three_pinch_combo, 1, 7); + pinch_grid.attach (four_pinch_label, 0, 8); + pinch_grid.attach (four_pinch_combo, 1, 8); + + var pinch_header = new Granite.HeaderLabel (_("Pinch")) { + margin_top = 12, + mnemonic_widget = pinch_grid + }; + + var content_area = new Gtk.Box (VERTICAL, 12); + content_area.append (horizontal_swipe_header); + content_area.append (horizontal_swipe_grid); + content_area.append (swipe_up_header); + content_area.append (swipe_up_grid); + content_area.append (pinch_header); + content_area.append (pinch_grid); child = content_area; From c3600a315f1bd1704c4fa8b1d4b4a89a53aafd74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 15 Aug 2024 17:22:33 -0700 Subject: [PATCH 2/2] Start dropdown port --- src/Views/Gestures.vala | 56 +++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/src/Views/Gestures.vala b/src/Views/Gestures.vala index 7851fabd..ca2c169a 100644 --- a/src/Views/Gestures.vala +++ b/src/Views/Gestures.vala @@ -29,28 +29,42 @@ public class MouseTouchpad.GesturesView : Switchboard.SettingsPage { construct { show_end_title_buttons = true; - var three_swipe_horizontal_combo = new Gtk.ComboBoxText () { + var horizontal_liststore = new ListStore (typeof (GestureOption)); + horizontal_liststore.append (new GestureOption ("none", _("Do nothing"))); + horizontal_liststore.append (new GestureOption ("switch-to-workspace", _("Switch to workspace"))); + horizontal_liststore.append (new GestureOption ("move-to-workspace", _("Move active window to workspace"))); + horizontal_liststore.append (new GestureOption ("switch-windows", _("Cycle windows"))); + + var up_liststore = new ListStore (typeof (GestureOption)); + up_liststore.append (new GestureOption ("none", _("Do nothing"))); + up_liststore.append (new GestureOption ("multitasking-view", _("Multitasking View"))); + + var pinch_liststore = new ListStore (typeof (GestureOption)); + pinch_liststore.append (new GestureOption ("none", _("Do nothing"))); + pinch_liststore.append (new GestureOption ("multitasking-view", _("Multitasking View"))); + + var expression = new Gtk.PropertyExpression ( + typeof (GestureOption), + null, + "label" + ); + + var three_swipe_horizontal_dropdown = new Gtk.DropDown (horizontal_liststore, expression) { hexpand = true }; - three_swipe_horizontal_combo.append ("none", _("Do nothing")); - three_swipe_horizontal_combo.append ("switch-to-workspace", _("Switch to workspace")); - three_swipe_horizontal_combo.append ("move-to-workspace", _("Move active window to workspace")); - three_swipe_horizontal_combo.append ("switch-windows", _("Cycle windows")); var three_swipe_horizontal_label = new Gtk.Label (_("Three fingers:")) { halign = END, - mnemonic_widget = three_swipe_horizontal_combo + mnemonic_widget = three_swipe_horizontal_dropdown }; - var four_swipe_horizontal_combo = new Gtk.ComboBoxText (); - four_swipe_horizontal_combo.append ("none", _("Do nothing")); - four_swipe_horizontal_combo.append ("switch-to-workspace", _("Switch to workspace")); - four_swipe_horizontal_combo.append ("move-to-workspace", _("Move active window to workspace")); - four_swipe_horizontal_combo.append ("switch-windows", _("Cycle windows")); + var four_swipe_horizontal_dropdown = new Gtk.DropDown (horizontal_liststore, expression) { + hexpand = true + }; var four_swipe_horizontal_label = new Gtk.Label (_("Four fingers:")) { halign = END, - mnemonic_widget = four_swipe_horizontal_combo + mnemonic_widget = four_swipe_horizontal_dropdown }; var horizontal_swipe_grid = new Gtk.Grid () { @@ -59,9 +73,9 @@ public class MouseTouchpad.GesturesView : Switchboard.SettingsPage { row_spacing = 12 }; horizontal_swipe_grid.attach (three_swipe_horizontal_label, 0, 1); - horizontal_swipe_grid.attach (three_swipe_horizontal_combo, 1, 1); + horizontal_swipe_grid.attach (three_swipe_horizontal_dropdown, 1, 1); horizontal_swipe_grid.attach (four_swipe_horizontal_label, 0, 2); - horizontal_swipe_grid.attach (four_swipe_horizontal_combo, 1, 2); + horizontal_swipe_grid.attach (four_swipe_horizontal_dropdown, 1, 2); var horizontal_swipe_header = new Granite.HeaderLabel (_("Swipe Horizontally")) { mnemonic_widget = horizontal_swipe_grid @@ -148,8 +162,9 @@ public class MouseTouchpad.GesturesView : Switchboard.SettingsPage { child = content_area; var glib_settings = new GLib.Settings ("io.elementary.desktop.wm.gestures"); - glib_settings.bind ("three-finger-swipe-horizontal", three_swipe_horizontal_combo, "active-id", GLib.SettingsBindFlags.DEFAULT); - glib_settings.bind ("four-finger-swipe-horizontal", four_swipe_horizontal_combo, "active-id", GLib.SettingsBindFlags.DEFAULT); + glib_settings.bind ("three-finger-swipe-horizontal", three_swipe_horizontal_dropdown, "selected", DEFAULT); + glib_settings.bind ("four-finger-swipe-horizontal", four_swipe_horizontal_dropdown, "selected", DEFAULT); + glib_settings.bind ("three-finger-swipe-up", three_swipe_up_combo, "active-id", GLib.SettingsBindFlags.DEFAULT); glib_settings.bind ("four-finger-swipe-up", four_swipe_up_combo, "active-id", GLib.SettingsBindFlags.DEFAULT); glib_settings.bind ("three-finger-pinch", three_pinch_combo, "active-id", GLib.SettingsBindFlags.DEFAULT); @@ -183,4 +198,13 @@ public class MouseTouchpad.GesturesView : Switchboard.SettingsPage { }); } } + + private class GestureOption : Object { + public string name { get; construct; } + public string label { get; construct; } + + public GestureOption (string name, string label) { + Object (name: name, label: label); + } + } }