[grilo/wip/hadess/clean-source-notification] grilo-test-ui: Exit early when looping over sources
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo/wip/hadess/clean-source-notification] grilo-test-ui: Exit early when looping over sources
- Date: Fri, 21 Aug 2020 18:50:42 +0000 (UTC)
commit f046d421b3be054739b3e579c2e27ee430f23138
Author: Bastien Nocera <hadess hadess net>
Date: Fri Aug 21 20:11:28 2020 +0200
grilo-test-ui: Exit early when looping over sources
That would allow us to add more early exits when debugging, without
making the code more complicated. Also tidy up to not have a "source"
variable that's actually a GList element.
tools/grilo-test-ui/main.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/tools/grilo-test-ui/main.c b/tools/grilo-test-ui/main.c
index 17e5389..3738b26 100644
--- a/tools/grilo-test-ui/main.c
+++ b/tools/grilo-test-ui/main.c
@@ -340,7 +340,7 @@ changes_notification_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
- GList *sources, *source;
+ GList *sources, *l;
GrlRegistry *registry;
ui_state->changes_notification = g_variant_get_boolean (parameter);
@@ -348,21 +348,21 @@ changes_notification_cb (GSimpleAction *action,
registry = grl_registry_get_default ();
sources = grl_registry_get_sources (registry, FALSE);
- for (source = sources; source; source = g_list_next (source)) {
- if (grl_source_supported_operations (GRL_SOURCE (source->data)) &
- GRL_OP_NOTIFY_CHANGE) {
- if (ui_state->changes_notification) {
- grl_source_notify_change_start (GRL_SOURCE (source->data), NULL);
- g_signal_connect (GRL_SOURCE (source->data),
- "content-changed",
- G_CALLBACK (content_changed_cb),
- NULL);
- } else {
- grl_source_notify_change_stop (GRL_SOURCE (source->data), NULL);
- g_signal_handlers_disconnect_by_func (source->data,
- content_changed_cb,
- NULL);
- }
+ for (l = sources; l != NULL; l = g_list_next (l)) {
+ GrlSource *source = l->data;
+ if (!(grl_source_supported_operations (source) & GRL_OP_NOTIFY_CHANGE))
+ continue;
+ if (ui_state->changes_notification) {
+ grl_source_notify_change_start (GRL_SOURCE (source), NULL);
+ g_signal_connect (GRL_SOURCE (source),
+ "content-changed",
+ G_CALLBACK (content_changed_cb),
+ NULL);
+ } else {
+ grl_source_notify_change_stop (GRL_SOURCE (source), NULL);
+ g_signal_handlers_disconnect_by_func (source,
+ content_changed_cb,
+ NULL);
}
}
g_list_free (sources);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]