Commit ba06c531 authored by Jeremy Bicha's avatar Jeremy Bicha 🇧🇭

keymouse: Redesign Mouse Click Emulation section

Closes: #117
parent 53a8edb7
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import os.path import os.path
from gi.repository import GLib, Gtk, Gdk from gi.repository import Gio, GLib, Gtk, Gdk
import gtweak import gtweak
from gtweak.gsettings import GSettingsSetting from gtweak.gsettings import GSettingsSetting
...@@ -247,6 +247,117 @@ class AdditionalLayoutButton(Gtk.Box, Tweak): ...@@ -247,6 +247,117 @@ class AdditionalLayoutButton(Gtk.Box, Tweak):
dialog.add(scrolled_window) dialog.add(scrolled_window)
dialog.show_all() dialog.show_all()
class ClickMethod(Gtk.ListBox, Tweak):
def __init__(self, **options):
Gtk.ListBox.__init__(self)
Tweak.__init__(self, _("Mouse Click Emulation"), _("Mouse Click Emulation"))
self.settings = Gio.Settings("org.gnome.desktop.peripherals.touchpad")
self.key_name = "click-method"
self.set_selection_mode(Gtk.SelectionMode.NONE)
# Needs other page elements to get margins too
# self.props.margin_left = 50
# self.props.margin_right = 50
row = Gtk.ListBoxRow()
hbox = Gtk.Box()
hbox.props.margin = 10
row.add(hbox)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
lbl = Gtk.Label(_("Fingers"), xalign=0)
lbl.props.xalign = 0.0
desc = _("Click the touchpad with two fingers for right-click and three fingers for middle-click.")
lbl_desc = Gtk.Label()
lbl_desc.set_line_wrap(True)
lbl_desc.get_style_context().add_class("dim-label")
lbl_desc.set_markup("<span size='small'>"+GLib.markup_escape_text(desc)+"</span>")
self.check_fingers = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
self.check_fingers.set_no_show_all(True)
self.check_fingers.set_visible(self.settings[self.key_name] == "fingers")
vbox.pack_start(lbl, False, False, 0)
vbox.pack_start(lbl_desc, False, False, 0)
hbox.pack_start(vbox, False, False, 0)
hbox.pack_end(self.check_fingers, False, False, 0)
self.add(row)
row = Gtk.ListBoxRow()
hbox = Gtk.Box()
hbox.props.margin = 10
row.add(hbox)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
lbl = Gtk.Label(_("Area"), xalign=0)
lbl.props.xalign = 0.0
desc = _("Click the bottom right of the touchpad for right-click and the bottom middle for middle-click.")
lbl_desc = Gtk.Label()
lbl_desc.set_line_wrap(True)
lbl_desc.get_style_context().add_class("dim-label")
lbl_desc.set_markup("<span size='small'>"+GLib.markup_escape_text(desc)+"</span>")
self.check_area = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
self.check_area.set_no_show_all(True)
self.check_area.set_visible(self.settings[self.key_name] == "areas")
vbox.pack_start(lbl, False, False, 0)
vbox.pack_start(lbl_desc, False, False, 0)
hbox.pack_start(vbox, False, False, 0)
hbox.pack_end(self.check_area, False, False, 0)
self.add(row)
row = Gtk.ListBoxRow()
hbox = Gtk.Box()
hbox.props.margin = 10
row.add(hbox)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
lbl = Gtk.Label(_("Disabled"), xalign=0)
lbl.props.xalign = 0.0
desc = _("Don't use mouse click emulation.")
lbl_desc = Gtk.Label()
lbl_desc.set_line_wrap(True)
lbl_desc.get_style_context().add_class("dim-label")
lbl_desc.set_markup("<span size='small'>"+GLib.markup_escape_text(desc)+"</span>")
self.check_disabled = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
self.check_disabled.set_no_show_all(True)
self.check_disabled.set_visible(self.settings[self.key_name] == "none")
vbox.pack_start(lbl, False, False, 0)
vbox.pack_start(lbl_desc, False, False, 0)
hbox.pack_start(vbox, False, False, 0)
hbox.pack_end(self.check_disabled, False, False, 0)
self.add(row)
self.connect('row-activated', self.on_row_clicked)
def on_row_clicked(self, box, row):
if row.get_index() == 0:
self.settings[self.key_name] = "fingers"
self.check_fingers.show()
self.check_area.hide()
self.check_disabled.hide()
elif row.get_index() == 1:
self.settings[self.key_name] = "areas"
self.check_fingers.hide()
self.check_area.show()
self.check_disabled.hide()
else:
self.settings[self.key_name] = "none"
self.check_fingers.hide()
self.check_area.hide()
self.check_disabled.show()
TWEAK_GROUPS = [ TWEAK_GROUPS = [
ListBoxTweakGroup(_("Keyboard & Mouse"), ListBoxTweakGroup(_("Keyboard & Mouse"),
...@@ -275,13 +386,11 @@ TWEAK_GROUPS = [ ...@@ -275,13 +386,11 @@ TWEAK_GROUPS = [
"gtk-enable-primary-paste"), "gtk-enable-primary-paste"),
Title(_("Touchpad"), ""), Title(_("Touchpad"), ""),
GSettingsComboEnumTweak(_("Click Method"),
"org.gnome.desktop.peripherals.touchpad",
"click-method",
schema_filename="org.gnome.desktop.peripherals.gschema.xml"),
GSettingsSwitchTweak(_("Disable While Typing"), GSettingsSwitchTweak(_("Disable While Typing"),
"org.gnome.desktop.peripherals.touchpad", "org.gnome.desktop.peripherals.touchpad",
"disable-while-typing", "disable-while-typing",
schema_filename="org.gnome.desktop.peripherals.gschema.xml"), schema_filename="org.gnome.desktop.peripherals.gschema.xml"),
Title(_("Mouse Click Emulation"), _("Mouse Click Emulation"), top=True),
ClickMethod(),
), ),
] ]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment