diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-05-16 20:47:07 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-05-16 20:47:07 +0200 |
| commit | d0b647c3156b07c70e9831aa86ef76ee40413d0c (patch) | |
| tree | 0908404f80ea28db00962c8eeb26b042dad98cb9 /lib/src | |
| parent | 9e1280599c322df6e5f3e8bac2a56915bf8531f2 (diff) | |
| download | turns-d0b647c3156b07c70e9831aa86ef76ee40413d0c.tar.xz turns-d0b647c3156b07c70e9831aa86ef76ee40413d0c.zip | |
lib: react to priority changes
Diffstat (limited to 'lib/src')
| -rw-r--r-- | lib/src/turns-turn-order.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/src/turns-turn-order.cpp b/lib/src/turns-turn-order.cpp index 46ea0e6..b7bd03e 100644 --- a/lib/src/turns-turn-order.cpp +++ b/lib/src/turns-turn-order.cpp @@ -46,11 +46,11 @@ namespace if (left_priority < right_priority) { - return -1; + return 1; } else if (left_priority > right_priority) { - return 1; + return -1; } else { @@ -80,6 +80,11 @@ namespace } } + auto handle_participant_property_changed(TurnsParticipant const *, GParamSpec *, TurnsTurnOrder * self) + { + self->participants = g_slist_sort(self->participants, std::bit_cast<GCompareFunc>(&compare_participant)); + } + } // namespace G_BEGIN_DECLS @@ -140,6 +145,8 @@ void turns_turn_order_add(TurnsTurnOrder * self, TurnsParticipant * participant) { g_return_if_fail(participant != nullptr); self->participants = g_slist_insert_sorted(self->participants, g_object_ref(participant), std::bit_cast<GCompareFunc>(&compare_participant)); + + g_signal_connect(participant, "notify::priority", std::bit_cast<GCallback>(&handle_participant_property_changed), self); } gsize turns_turn_order_get_participant_count(TurnsTurnOrder const * self) |
