[gnome-shell/wip/carlosg/cleanup-gtk-usage: 74/77] dnd: Use GSettings instead of GtkSettings



commit 30e6bf248657e6a925d4a25a59f27f5b43deb2c7
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Nov 27 14:42:43 2018 +0100

    dnd: Use GSettings instead of GtkSettings
    
    Cut a middle man by listening to dconf settings directly, and stop relying
    on XSettings for it.

 js/ui/dnd.js | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/dnd.js b/js/ui/dnd.js
index 4aca7c341..d7ea2a143 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -1,8 +1,8 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
 const Clutter = imports.gi.Clutter;
+const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
-const Gtk = imports.gi.Gtk;
 const St = imports.gi.St;
 const Meta = imports.gi.Meta;
 const Shell = imports.gi.Shell;
@@ -109,6 +109,12 @@ var _Draggable = class _Draggable {
         this._dragCancellable = true;
 
         this._eventsGrabbed = false;
+
+        this._settings = new Gio.Settings({ schema_id: 'org.gnome.settings-daemon.peripherals.mouse' });
+        this._settings.connect ('changed::drag-threshold', () => {
+            this._dragThreshold = this._settings.get_int('drag-threshold');
+        });
+        this._dragThreshold = this._settings.get_int('drag-threshold');
     }
 
     _onButtonPress(actor, event) {
@@ -398,9 +404,8 @@ var _Draggable = class _Draggable {
         let [stageX, stageY] = event.get_coords();
 
         // See if the user has moved the mouse enough to trigger a drag
-        let threshold = Gtk.Settings.get_default().gtk_dnd_drag_threshold;
-        if ((Math.abs(stageX - this._dragStartX) > threshold ||
-             Math.abs(stageY - this._dragStartY) > threshold)) {
+        if ((Math.abs(stageX - this._dragStartX) > this._dragThreshold ||
+             Math.abs(stageY - this._dragStartY) > this._dragThreshold)) {
             this.startDrag(stageX, stageY, event.get_time(), this._touchSequence);
             this._updateDragPosition(event);
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]