Skip to content

Commit

Permalink
Pointing: Vertical layout and cleanup (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Jan 24, 2024
1 parent 62dd189 commit 4870cff
Showing 1 changed file with 30 additions and 67 deletions.
97 changes: 30 additions & 67 deletions src/Views/Pointing.vala
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
/*
* Copyright (c) 2011-2020 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
* SPDX-License-Identifier: GPL-2.0-or-later
* SPDX-FileCopyrightText: 2011-2024 elementary, Inc. (https://elementary.io)
*/

public class MouseTouchpad.PointingView : Granite.SimpleSettingsPage {
Expand All @@ -27,28 +13,23 @@ public class MouseTouchpad.PointingView : Granite.SimpleSettingsPage {

construct {
var keypad_pointer_switch = new Gtk.Switch () {
halign = Gtk.Align.START,
valign = Gtk.Align.CENTER
halign = END,
valign = CENTER
};

var keypad_pointer_adjustment = new Gtk.Adjustment (0, 0, 500, 10, 10, 10);

var pointer_speed_label = new Gtk.Label (_("Speed:")) {
halign = Gtk.Align.END
var keypad_pointer_header = new Granite.HeaderLabel (_("Control Pointer Using Keypad")) {
secondary_text = _("This disables both levels of keys on the numeric keypad"),
mnemonic_widget = keypad_pointer_switch
};

var pointer_speed_scale = new Gtk.Scale (Gtk.Orientation.HORIZONTAL, keypad_pointer_adjustment) {
draw_value = false,
hexpand = true,
margin_top = 7
};
pointer_speed_scale.add_mark (10, Gtk.PositionType.BOTTOM, null);
var keypad_pointer_adjustment = new Gtk.Adjustment (0, 0, 1000, 10, 10, 10);

var pointer_speed_help = new Gtk.Label (_("This disables both levels of keys on the numeric keypad")) {
wrap = true,
xalign = 0
var pointer_speed_scale = new Gtk.Scale (HORIZONTAL, keypad_pointer_adjustment) {
hexpand = true
};
pointer_speed_help.add_css_class (Granite.STYLE_CLASS_DIM_LABEL);
pointer_speed_scale.add_mark (0, BOTTOM, _("Slower"));
pointer_speed_scale.add_mark (100, BOTTOM, null);
pointer_speed_scale.add_mark (990, BOTTOM, _("Faster"));

var cursor_size_24 = new Gtk.CheckButton () {
tooltip_text = _("Small")
Expand Down Expand Up @@ -82,73 +63,55 @@ public class MouseTouchpad.PointingView : Granite.SimpleSettingsPage {
};
cursor_size_48_image.set_parent (cursor_size_48);

var cursor_size_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 24);
var cursor_size_box = new Gtk.Box (HORIZONTAL, 24);
cursor_size_box.append (cursor_size_24);
cursor_size_box.append (cursor_size_32);
cursor_size_box.append (cursor_size_48);

var locate_pointer_help = new Gtk.Label (
_("Pressing the control key will highlight the position of the pointer")
) {
margin_bottom = 18,
wrap = true,
xalign = 0
};
locate_pointer_help.add_css_class (Granite.STYLE_CLASS_DIM_LABEL);

var reveal_pointer_label = new Gtk.Label (_("Reveal pointer:")) {
margin_top = 18,
halign = Gtk.Align.END
var reveal_pointer_switch = new Gtk.Switch () {
halign = END,
valign = CENTER
};

var reveal_pointer_switch = new Gtk.Switch () {
halign = Gtk.Align.START,
margin_top = 18
var reveal_pointer_label = new Granite.HeaderLabel (_("Reveal Pointer")) {
mnemonic_widget = reveal_pointer_switch,
secondary_text = _("Pressing the control key will highlight the position of the pointer")
};

content_area.row_spacing = 6;

content_area.attach (new Gtk.Label (_("Pointer size:")) { halign = Gtk.Align.END }, 0, 0);
content_area.attach (cursor_size_box, 1, 0, 3);
content_area.attach (new Granite.HeaderLabel (_("Pointer Size")), 0, 0);
content_area.attach (cursor_size_box, 0, 1);

content_area.attach (reveal_pointer_label, 0, 1);
content_area.attach (reveal_pointer_switch, 1, 1, 3);
content_area.attach (locate_pointer_help, 1, 2, 3);
content_area.attach (reveal_pointer_label, 0, 2);
content_area.attach (reveal_pointer_switch, 1, 2);

content_area.attach (new Gtk.Label (_("Control pointer using keypad:")) { halign = Gtk.Align.END }, 0, 3);
content_area.attach (keypad_pointer_header, 0, 3);
content_area.attach (keypad_pointer_switch, 1, 3);
content_area.attach (pointer_speed_label, 2, 3);
content_area.attach (pointer_speed_scale, 3, 3);
content_area.attach (pointer_speed_help, 1, 4, 3);
content_area.attach (pointer_speed_scale, 0, 4, 2);

var a11y_keyboard_settings = new GLib.Settings ("org.gnome.desktop.a11y.keyboard");
a11y_keyboard_settings.bind (
"mousekeys-enable",
keypad_pointer_switch,
"active",
GLib.SettingsBindFlags.DEFAULT
DEFAULT
);
a11y_keyboard_settings.bind (
"mousekeys-max-speed",
keypad_pointer_adjustment,
"value",
SettingsBindFlags.DEFAULT
DEFAULT
);
a11y_keyboard_settings.bind (
"mousekeys-enable",
pointer_speed_scale,
"sensitive",
SettingsBindFlags.GET
);
a11y_keyboard_settings.bind (
"mousekeys-enable",
pointer_speed_label,
"sensitive",
SettingsBindFlags.GET
GET
);

var interface_settings = new GLib.Settings ("org.gnome.desktop.interface");
interface_settings.bind ("locate-pointer", reveal_pointer_switch, "active", GLib.SettingsBindFlags.DEFAULT);
interface_settings.bind ("locate-pointer", reveal_pointer_switch, "active", DEFAULT);

switch (interface_settings.get_int ("cursor-size")) {
case 32:
Expand Down

0 comments on commit 4870cff

Please sign in to comment.