11/*
2- * Copyright 2011-2022 elementary, Inc. (https://elementary.io)
3- *
4- * This program is free software; you can redistribute it and/or
5- * modify it under the terms of the GNU General Public
6- * License as published by the Free Software Foundation; either
7- * version 2 of the License, or (at your option) any later version.
8- *
9- * This program is distributed in the hope that it will be useful,
10- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12- * General Public License for more details.
13- *
14- * You should have received a copy of the GNU General Public
15- * License along with this program; if not, write to the
16- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17- * Boston, MA 02110-1301 USA.
2+ * SPDX-License-Identifier: GPL-2.0-or-later
3+ * SPDX-FileCopyrightText: 2011-2026 elementary, Inc. (https://elementary.io)
184 */
195
206public class MouseTouchpad.ClickingView : Switchboard .SettingsPage {
@@ -29,33 +15,27 @@ public class MouseTouchpad.ClickingView : Switchboard.SettingsPage {
2915 construct {
3016 show_end_title_buttons = true ;
3117
32- var primary_button_label = new Granite .HeaderLabel (_(" Primary Button" ));
33-
3418 var mouse_left = new Gtk .CheckButton () {
19+ child = new Gtk .Image .from_icon_name (" mouse-left-symbolic" ) {
20+ pixel_size = 32
21+ },
3522 // / TRANSLATORS: Used as "Primary Button: Left"
3623 tooltip_text = NC_ ("mouse -button ", "Left ")
3724 };
3825 mouse_left.add_css_class ("image -button ");
3926
40- var mouse_left_image = new Gtk .Image .from_icon_name (" mouse-left-symbolic" ) {
41- pixel_size = 32
42- };
43- mouse_left_image.set_parent (mouse_left );
44-
4527 var mouse_right = new Gtk .CheckButton () {
28+ child = new Gtk .Image .from_icon_name (" mouse-right-symbolic" ) {
29+ pixel_size = 32
30+ },
4631 group = mouse_left,
4732 // / TRANSLATORS: Used as "Primary Button: Right";
4833 tooltip_text = NC_ ("mouse -button ", "Right ")
4934 };
5035 mouse_right.add_css_class ("image -button ");
5136
52- var mouse_right_image = new Gtk .Image .from_icon_name (" mouse-right-symbolic" ) {
53- pixel_size = 32
54- };
55- mouse_right_image.set_parent (mouse_right );
56-
57- var primary_button_switcher = new Gtk .Box (Gtk . Orientation . HORIZONTAL , 24 ) {
58- halign = Gtk . Align . START ,
37+ var primary_button_switcher = new Granite .Box (HORIZONTAL , DOUBLE ) {
38+ halign = START ,
5939 margin_bottom = 12
6040 };
6141
@@ -67,9 +47,13 @@ public class MouseTouchpad.ClickingView : Switchboard.SettingsPage {
6747 primary_button_switcher. append (mouse_left);
6848 }
6949
50+ var primary_button_label = new Granite .HeaderLabel (_(" Primary Button" )) {
51+ mnemonic_widget = primary_button_switcher
52+ };
53+
7054 var hold_switch = new Gtk .Switch () {
71- halign = Gtk . Align . END ,
72- valign = Gtk . Align . CENTER
55+ halign = END ,
56+ valign = CENTER
7357 };
7458
7559 var hold_header = new Granite .HeaderLabel (_(" Long-press Secondary Click" )) {
@@ -79,38 +63,38 @@ public class MouseTouchpad.ClickingView : Switchboard.SettingsPage {
7963
8064 var hold_scale_adjustment = new Gtk .Adjustment (0 , 0.5 , 3 , 0.1 , 0.1 , 0.1 );
8165
82- var hold_scale = new Gtk .Scale (Gtk . Orientation . HORIZONTAL , hold_scale_adjustment) {
66+ var hold_scale = new Gtk .Scale (HORIZONTAL , hold_scale_adjustment) {
8367 draw_value = false ,
8468 hexpand = true
8569 };
86- hold_scale.add_mark (1 .2 , Gtk . PositionType . BOTTOM , null );
70+ hold_scale.add_mark (1 .2 , BOTTOM , null );
8771
8872 var hold_spinbutton = new Gtk .SpinButton (hold_scale_adjustment, 1 , 1 ) {
8973 width_chars = 10 ,
90- valign = Gtk . Align . START
74+ valign = START
9175 };
9276
93- var hold_spin_box = new Gtk .Box (Gtk . Orientation . HORIZONTAL , 12 ) {
77+ var hold_spin_box = new Gtk .Box (HORIZONTAL , 12 ) {
9478 margin_bottom = 12
9579 };
9680 hold_spin_box.append (hold_scale );
9781 hold_spin_box.append (hold_spinbutton );
9882
9983 var double_click_speed_adjustment = new Gtk .Adjustment (400 , 100 , 1000 , 0.1 , 0.1 , 0.1 );
10084
101- var double_click_speed_scale = new Gtk .Scale (Gtk . Orientation . HORIZONTAL , double_click_speed_adjustment) {
85+ var double_click_speed_scale = new Gtk .Scale (HORIZONTAL , double_click_speed_adjustment) {
10286 draw_value = false
10387 };
104- double_click_speed_scale.add_mark (400 , Gtk . PositionType . BOTTOM , null );
88+ double_click_speed_scale.add_mark (400 , BOTTOM , null );
10589
10690 var double_click_header = new Granite .HeaderLabel (_(" Double-click Speed" )) {
10791 mnemonic_widget = double_click_speed_scale,
10892 secondary_text = _ ("How quickly two clicks in a row will be treated as a double -click ")
10993 };
11094
11195 var dwell_click_switch = new Gtk .Switch () {
112- halign = Gtk . Align . END ,
113- valign = Gtk . Align . CENTER
96+ halign = END ,
97+ valign = CENTER
11498 };
11599
116100 var dwell_click_header = new Granite .HeaderLabel (_(" Dwell Click" )) {
@@ -120,23 +104,34 @@ public class MouseTouchpad.ClickingView : Switchboard.SettingsPage {
120104
121105 var dwell_click_adjustment = new Gtk .Adjustment (0 , 0.5 , 3 , 0.1 , 0.1 , 0.1 );
122106
123- var dwell_click_delay_scale = new Gtk .Scale (Gtk . Orientation . HORIZONTAL , dwell_click_adjustment) {
107+ var dwell_click_delay_scale = new Gtk .Scale (HORIZONTAL , dwell_click_adjustment) {
124108 draw_value = false ,
125109 hexpand = true
126110 };
127- dwell_click_delay_scale.add_mark (1 .2 , Gtk . PositionType . BOTTOM , null );
111+ dwell_click_delay_scale.add_mark (1 .2 , BOTTOM , null );
128112
129113 var dwell_click_spinbutton = new Gtk .SpinButton (dwell_click_adjustment, 1 , 1 ) {
130114 width_chars = 10 ,
131- valign = Gtk . Align . START
115+ valign = START
132116 };
133117
134- var dwell_click_spin_box = new Gtk .Box (Gtk . Orientation . HORIZONTAL , 12 ) {
118+ var dwell_click_spin_box = new Gtk .Box (HORIZONTAL , 12 ) {
135119 margin_bottom = 12
136120 };
137121 dwell_click_spin_box.append (dwell_click_delay_scale );
138122 dwell_click_spin_box.append (dwell_click_spinbutton );
139123
124+ var primary_paste_switch = new Gtk .Switch () {
125+ action_name = " clicking.gtk-enable-primary-paste" ,
126+ halign = END ,
127+ valign = CENTER
128+ };
129+
130+ var primary_paste_header = new Granite .HeaderLabel (_(" Middle Click Paste" )) {
131+ mnemonic_widget = primary_paste_switch,
132+ secondary_text = _ ("Middle or three -finger click on an input to paste selected text ")
133+ };
134+
140135 var content_area = new Gtk .Grid () {
141136 row_spacing = 6
142137 };
@@ -155,69 +150,30 @@ public class MouseTouchpad.ClickingView : Switchboard.SettingsPage {
155150 content_area.attach (hold_switch , 1 , 6 );
156151 content_area.attach (hold_spin_box , 0 , 7 , 2 );
157152
153+ content_area.attach (primary_paste_header , 0 , 8 );
154+ content_area.attach (primary_paste_switch , 1 , 8 );
155+
158156 child = content_area;
159157
160158 var action_group = new SimpleActionGroup ();
161159 action_group.add_action (new GLib .Settings ("org .gnome .desktop .interface ").create_action ("gtk -enable -primary -paste "));
162160
163161 insert_action_group ("clicking ", action_group );
164162
165- var primary_paste_switch = new Gtk .Switch () {
166- action_name = " clicking.gtk-enable-primary-paste" ,
167- halign = Gtk . Align . END ,
168- valign = Gtk . Align . CENTER
169- };
170-
171- var primary_paste_header = new Granite .HeaderLabel (_(" Middle Click Paste" )) {
172- mnemonic_widget = primary_paste_switch,
173- secondary_text = _ ("Middle or three -finger click on an input to paste selected text ")
174- };
175-
176- content_area.attach (primary_paste_header , 0 , 8 );
177- content_area.attach (primary_paste_switch , 1 , 8 );
178-
179163 var a11y_mouse_settings = new GLib .Settings (" org.gnome.desktop.a11y.mouse" );
180- a11y_mouse_settings.bind (
181- "secondary -click -enabled ",
182- hold_switch ,
183- "active ",
184- GLib .SettingsBindFlags .DEFAULT
185- );
186- a11y_mouse_settings.bind (
187- "secondary -click -time ",
188- hold_scale_adjustment ,
189- "value ",
190- GLib .SettingsBindFlags .DEFAULT
191- );
192-
193- a11y_mouse_settings.bind ("dwell -click -enabled ", dwell_click_delay_scale , "sensitive ", SettingsBindFlags .GET );
194- a11y_mouse_settings.bind ("dwell -click -enabled ", dwell_click_spin_box , "sensitive ", SettingsBindFlags .GET );
195- a11y_mouse_settings.bind ("dwell -click -enabled ", dwell_click_switch , "active ", SettingsBindFlags .DEFAULT );
196- a11y_mouse_settings.bind ("dwell -time ", dwell_click_adjustment , "value ", SettingsBindFlags .DEFAULT );
164+ a11y_mouse_settings.bind ("secondary -click -enabled ", hold_switch , "active ", DEFAULT );
165+ a11y_mouse_settings.bind ("secondary -click -enabled ", hold_scale , "sensitive ", DEFAULT );
166+ a11y_mouse_settings.bind ("secondary -click -enabled ", hold_spin_box , "sensitive ", DEFAULT );
167+ a11y_mouse_settings.bind ("secondary -click -time ", hold_scale_adjustment , "value ", DEFAULT );
197168
198- hold_switch.bind_property ("active ", hold_scale , "sensitive ", BindingFlags .SYNC_CREATE );
199- hold_switch.bind_property ("active ", hold_spin_box , "sensitive ", BindingFlags .SYNC_CREATE );
169+ a11y_mouse_settings.bind ("dwell -click -enabled ", dwell_click_delay_scale , "sensitive ", GET );
170+ a11y_mouse_settings.bind ("dwell -click -enabled ", dwell_click_spin_box , "sensitive ", GET );
171+ a11y_mouse_settings.bind ("dwell -click -enabled ", dwell_click_switch , "active ", DEFAULT );
172+ a11y_mouse_settings.bind ("dwell -time ", dwell_click_adjustment , "value ", DEFAULT );
200173
201174 var mouse_settings = new GLib .Settings (" org.gnome.desktop.peripherals.mouse" );
202- mouse_settings.bind ("double -click ", double_click_speed_adjustment , "value ", SettingsBindFlags .DEFAULT );
203-
204- if (mouse_settings .get_boolean ("left -handed ")) {
205- mouse_right. active = true ;
206- } else {
207- mouse_left. active = true ;
208- }
209-
210- mouse_left.toggled.connect (() => {
211- if (mouse_left. active) {
212- mouse_settings. set_boolean (" left-handed" , false );
213- }
214- });
215-
216- mouse_right.toggled.connect (() => {
217- if (mouse_right. active) {
218- mouse_settings. set_boolean (" left-handed" , true );
219- }
220- });
175+ mouse_settings.bind ("double -click ", double_click_speed_adjustment , "value ", DEFAULT );
176+ mouse_settings.bind ("left -handed ", mouse_right , "active ", DEFAULT );
221177
222178 dwell_click_spinbutton.output.connect (() => {
223179 dwell_click_spinbutton. text = _(" %.1f seconds" ). printf (dwell_click_adjustment. value );
0 commit comments