Skip to content

Commit

Permalink
Start dropdown port
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Aug 16, 2024
1 parent eb57870 commit c3600a3
Showing 1 changed file with 40 additions and 16 deletions.
56 changes: 40 additions & 16 deletions src/Views/Gestures.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit c3600a3

Please sign in to comment.