[grilo/wip/hadess/coding-style: 4/4] grilo-test-ui: Exit early when looping over sources
- From: Victor Toso <victortoso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo/wip/hadess/coding-style: 4/4] grilo-test-ui: Exit early when looping over sources
- Date: Wed, 2 Sep 2020 06:46:21 +0000 (UTC)
commit 1e75bf32a9bc5bd4abe0085d9707fa843505fb7d
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 e2335e6..eb6f343 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]