Skip to content

Commit 058bc90

Browse files
authored
Library: Use dedicated row widgets in 'Location' demo (#654)
1 parent a598cd8 commit 058bc90

File tree

3 files changed

+26
-39
lines changed

3 files changed

+26
-39
lines changed

src/Library/demos/Location/main.blp

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,31 @@ Adw.StatusPage {
1919

2020
styles ["boxed-list"]
2121

22-
Adw.ActionRow {
22+
Adw.SpinRow distance_threshold {
2323
title: _("Distance Threshold");
2424
subtitle: _("In meters");
25-
26-
SpinButton distance_threshold {
27-
valign: center;
28-
wrap: true;
25+
wrap: true;
26+
value: 0;
27+
climb-rate: 1;
28+
adjustment: Adjustment {
29+
lower: 0;
30+
upper: 100;
31+
step-increment: 1;
2932
value: 0;
30-
climb-rate: 1;
31-
adjustment: Adjustment {
32-
lower: 0;
33-
upper: 100;
34-
step-increment: 1;
35-
value: 0;
36-
};
37-
}
33+
};
3834
}
3935

40-
Adw.ActionRow {
36+
Adw.SpinRow time_threshold {
4137
title: _("Time Threshold");
42-
subtitle: _("In meters");
43-
44-
SpinButton time_threshold {
45-
valign: center;
46-
wrap: true;
38+
subtitle: _("In seconds");
39+
value: 0;
40+
climb-rate: 1;
41+
adjustment: Adjustment {
42+
lower: 0;
43+
upper: 100;
44+
step-increment: 1;
4745
value: 0;
48-
climb-rate: 1;
49-
adjustment: Adjustment {
50-
lower: 0;
51-
upper: 100;
52-
step-increment: 1;
53-
value: 0;
54-
};
55-
}
46+
};
5647
}
5748

5849
Adw.ComboRow accuracy_button {
@@ -171,7 +162,3 @@ Adw.StatusPage {
171162
}
172163
}
173164
}
174-
175-
176-
177-

src/Library/demos/Location/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ let locationAccuracy = Xdp.LocationAccuracy.Exact;
3131
let distanceThreshold = distance_threshold.value;
3232
let timeThreshold = time_threshold.value;
3333

34-
time_threshold.connect("value-changed", () => {
34+
time_threshold.connect("notify::value", () => {
3535
portal.location_monitor_stop();
3636
revealer.reveal_child = false;
3737
timeThreshold = time_threshold.value;
3838
console.log("Time threshold changed");
3939
startSession();
4040
});
4141

42-
distance_threshold.connect("value-changed", () => {
42+
distance_threshold.connect("notify::value", () => {
4343
portal.location_monitor_stop();
4444
revealer.reveal_child = false;
4545
distanceThreshold = distance_threshold.value;

src/Library/demos/Location/main.vala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ private Xdp.Parent parent;
66
private Gtk.Revealer revealer;
77
private Gtk.Button start_button;
88
private Gtk.Button close_button;
9-
private Gtk.SpinButton distance_threshold;
10-
private Gtk.SpinButton time_threshold;
9+
private Adw.SpinRow distance_threshold;
10+
private Adw.SpinRow time_threshold;
1111
private Adw.ComboRow accuracy_button;
1212

1313
private Gtk.Label latitude_label;
@@ -26,8 +26,8 @@ public void main () {
2626
revealer = (Gtk.Revealer) workbench.builder.get_object ("revealer");
2727
start_button = (Gtk.Button) workbench.builder.get_object ("start");
2828
close_button = (Gtk.Button) workbench.builder.get_object ("close");
29-
distance_threshold = (Gtk.SpinButton) workbench.builder.get_object ("distance_threshold");
30-
time_threshold = (Gtk.SpinButton) workbench.builder.get_object ("time_threshold");
29+
distance_threshold = (Adw.SpinRow) workbench.builder.get_object ("distance_threshold");
30+
time_threshold = (Adw.SpinRow) workbench.builder.get_object ("time_threshold");
3131
accuracy_button = (Adw.ComboRow) workbench.builder.get_object ("accuracy_button");
3232

3333
latitude_label = (Gtk.Label) workbench.builder.get_object ("latitude");
@@ -42,12 +42,12 @@ public void main () {
4242
start_button.clicked.connect (start_session);
4343
close_button.clicked.connect (close_session);
4444

45-
time_threshold.value_changed.connect (() => {
45+
time_threshold.notify["value"].connect (() => {
4646
message ("Time threshold changed");
4747
restart_session ();
4848
});
4949

50-
distance_threshold.value_changed.connect (() => {
50+
distance_threshold.notify["value"].connect (() => {
5151
message ("Distance threshold changed");
5252
restart_session ();
5353
});

0 commit comments

Comments
 (0)