|
18 | 18 | */ |
19 | 19 |
|
20 | 20 | public class MouseTouchpad.ClickingView : Switchboard.SettingsPage { |
| 21 | + private GLib.Settings? xsettings; |
| 22 | + private GLib.Settings interface_settings; |
| 23 | + |
21 | 24 | public ClickingView () { |
22 | 25 | Object ( |
23 | 26 | header: _("Behavior"), |
@@ -161,35 +164,40 @@ public class MouseTouchpad.ClickingView : Switchboard.SettingsPage { |
161 | 164 | "org.gnome.settings-daemon.plugins.xsettings", |
162 | 165 | true |
163 | 166 | ); |
164 | | - |
165 | 167 | if (xsettings_schema != null) { |
166 | | - var primary_paste_switch = new Gtk.Switch () { |
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 | | - |
179 | | - var xsettings = new GLib.Settings ("org.gnome.settings-daemon.plugins.xsettings"); |
180 | | - primary_paste_switch.notify["active"].connect (() => { |
181 | | - on_primary_paste_switch_changed (primary_paste_switch, xsettings); |
182 | | - }); |
183 | | - |
184 | | - var current_value = xsettings.get_value ("overrides").lookup_value ( |
185 | | - "Gtk/EnablePrimaryPaste", |
186 | | - VariantType.INT32 |
187 | | - ); |
188 | | - if (current_value != null) { |
189 | | - primary_paste_switch.active = current_value.get_int32 () == 1; |
| 168 | + xsettings = new GLib.Settings ("org.gnome.settings-daemon.plugins.xsettings"); |
| 169 | + } |
| 170 | + |
| 171 | + interface_settings = new GLib.Settings ("org.gnome.desktop.interface"); |
| 172 | + |
| 173 | + var primary_paste_switch = new Gtk.Switch () { |
| 174 | + halign = Gtk.Align.END, |
| 175 | + valign = Gtk.Align.CENTER |
| 176 | + }; |
| 177 | + |
| 178 | + var primary_paste_header = new Granite.HeaderLabel (_("Middle Click Paste")) { |
| 179 | + mnemonic_widget = primary_paste_switch, |
| 180 | + secondary_text = _("Middle or three-finger click on an input to paste selected text") |
| 181 | + }; |
| 182 | + |
| 183 | + content_area.attach (primary_paste_header, 0, 8); |
| 184 | + content_area.attach (primary_paste_switch, 1, 8); |
| 185 | + |
| 186 | + primary_paste_switch.notify["active"].connect (() => { |
| 187 | + on_primary_paste_switch_changed (primary_paste_switch); |
| 188 | + }); |
| 189 | + |
| 190 | + var current_x_value = false; |
| 191 | + if (xsettings != null) { |
| 192 | + var value = xsettings.get_value ("overrides").lookup_value ("Gtk/EnablePrimaryPaste", VariantType.INT32); |
| 193 | + if (value != null) { |
| 194 | + current_x_value = value.get_int32 () == 1; |
190 | 195 | } |
191 | 196 | } |
192 | 197 |
|
| 198 | + var current_wayland_value = interface_settings.get_boolean ("gtk-enable-primary-paste"); |
| 199 | + primary_paste_switch.active = current_wayland_value || current_x_value; |
| 200 | + |
193 | 201 | var a11y_mouse_settings = new GLib.Settings ("org.gnome.desktop.a11y.mouse"); |
194 | 202 | a11y_mouse_settings.bind ( |
195 | 203 | "secondary-click-enabled", |
@@ -244,12 +252,16 @@ public class MouseTouchpad.ClickingView : Switchboard.SettingsPage { |
244 | 252 | }); |
245 | 253 | } |
246 | 254 |
|
247 | | - private void on_primary_paste_switch_changed (Gtk.Switch switch, GLib.Settings xsettings) { |
248 | | - var overrides = xsettings.get_value ("overrides"); |
249 | | - var dict = new VariantDict (overrides); |
250 | | - dict.insert_value ("Gtk/EnablePrimaryPaste", new Variant.int32 (switch.active ? 1 : 0)); |
| 255 | + private void on_primary_paste_switch_changed (Gtk.Switch switch) { |
| 256 | + if (xsettings != null) { |
| 257 | + var overrides = xsettings.get_value ("overrides"); |
| 258 | + var dict = new VariantDict (overrides); |
| 259 | + dict.insert_value ("Gtk/EnablePrimaryPaste", new Variant.int32 (switch.active ? 1 : 0)); |
| 260 | + |
| 261 | + overrides = dict.end (); |
| 262 | + xsettings.set_value ("overrides", overrides); |
| 263 | + } |
251 | 264 |
|
252 | | - overrides = dict.end (); |
253 | | - xsettings.set_value ("overrides", overrides); |
| 265 | + interface_settings.set_boolean ("gtk-enable-primary-paste", switch.active); |
254 | 266 | } |
255 | 267 | } |
0 commit comments