Skip to content

Commit

Permalink
Add check for stylus detection (#70)
Browse files Browse the repository at this point in the history
* Add check for stylus detection

* Evaluate Boolean directly

* Update metainfo with a description of the fix

* Use issues tag in metainfo

* Update issue titile
  • Loading branch information
stsdc authored Dec 17, 2024
1 parent db18e22 commit 45a453b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
12 changes: 12 additions & 0 deletions data/wacom.metainfo.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@
<update_contact>contact_at_elementary.io</update_contact>

<releases>
<release version="8.0.1" date="2024-12-17" urgency="medium">
<description>
<p>Updates:</p>
<ul>
<li>Updated translations</li>
</ul>
</description>
<issues>
<issue url="https://github.com/elementary/switchboard-plug-wacom/issues/69">Clicking on the Wacom plug crushes Settings, because stylus is not detected by libwacom</issue>
</issues>
</release>

<release version="8.0.0" date="2024-07-02" urgency="medium">
<description>
<p>A Big Redesign!</p>
Expand Down
8 changes: 5 additions & 3 deletions src/MainPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class Wacom.MainPage : Switchboard.SettingsPage {
return;
}

if (tools.size > 0) {
if (tools.size > 0 && stylus_view.is_stylus_supported (tools[0])) {
stylus_view.set_device (tools[0]);
stylus_stack.visible_child = stylus_view;
}
Expand Down Expand Up @@ -131,8 +131,10 @@ public class Wacom.MainPage : Switchboard.SettingsPage {
}

if (wacom_tool != last_stylus) {
stylus_view.set_device (wacom_tool);
stylus_stack.visible_child = stylus_view;
if (stylus_view.is_stylus_supported (wacom_tool)) {
stylus_view.set_device (wacom_tool);
stylus_stack.visible_child = stylus_view;
}
}

last_stylus = wacom_tool;
Expand Down
5 changes: 5 additions & 0 deletions src/Views/StylusView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public class Wacom.StylusView : Gtk.Box {
append (stylus_box);
}

public bool is_stylus_supported (Backend.WacomTool wacom_tool) {
unowned var stylus = wacom_db.get_stylus_for_id ((int) wacom_tool.id);
return stylus != null;
}

public void set_device (Backend.WacomTool wacom_tool) {
while (stylus_box.get_first_child () != null) {
stylus_box.remove (stylus_box.get_first_child ());
Expand Down

0 comments on commit 45a453b

Please sign in to comment.