Skip to content

Commit

Permalink
StylusView: move settings here
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Mar 13, 2024
1 parent 9ae43c1 commit 2b3981c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
28 changes: 9 additions & 19 deletions src/Backend/WacomTool.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public errordomain WacomException {
public class Wacom.Backend.WacomTool : GLib.Object {
public uint64 id { public get; construct; }
public uint64 serial { public get; construct; }
public Backend.Device? device { get; construct; }
public string vendor_id { get; construct; }
public string product_id { get; construct; }

public unowned Wacom.Stylus? stylus { get; private set; default = null; }

private GLib.Settings? settings = null;
private static Wacom.DeviceDatabase? wacom_db = null;

public WacomTool (uint64 serial, uint64 id, Backend.Device? device) throws WacomException {
Expand All @@ -49,29 +49,19 @@ public class Wacom.Backend.WacomTool : GLib.Object {
}
}

Object (id: id, serial: serial, device: device);
Object (
id: id,
serial: serial,
vendor_id: device.vendor_id,
product_id: device.product_id
);
}

construct {
stylus = wacom_db.get_stylus_for_id ((int)this.id);
stylus = wacom_db.get_stylus_for_id ((int) id);

if (stylus == null) {
throw new WacomException.LIBWACOM_ERROR ("Stylus description not found");
}

string settings_path;
if (this.serial == 0) {
settings_path = "/org/gnome/desktop/peripherals/stylus/default-%s:%s/".printf (
device.vendor_id, device.product_id
);
} else {
settings_path = "/org/gnome/desktop/peripherals/stylus/%llx/".printf (this.serial);
}

settings = new GLib.Settings.with_path ("org.gnome.desktop.peripherals.tablet.stylus", settings_path);
}

public GLib.Settings get_settings () {
return settings;
}
}
11 changes: 10 additions & 1 deletion src/Views/StylusView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,16 @@ public class Wacom.StylusView : Gtk.Box {

stylus_box.add (header_box);

settings = device.get_settings ();
string settings_path;
if (device.serial == 0) {
settings_path = "/org/gnome/desktop/peripherals/stylus/default-%s:%s/".printf (
device.vendor_id, device.product_id
);
} else {
settings_path = "/org/gnome/desktop/peripherals/stylus/%llx/".printf (device.serial);
}

settings = new Settings.with_path ("org.gnome.desktop.peripherals.tablet.stylus", settings_path);

var has_pressure_detection = Wacom.AxisTypeFlags.PRESSURE in device.stylus.get_axes ();

Expand Down

0 comments on commit 2b3981c

Please sign in to comment.