[gnome-initial-setup/wjt/more-timezone-fixes: 5/5] location-entry: refactor handling geocode results




commit f94db9d4fd2233393a56d61abe557c1e0de0efb5
Author: Will Thompson <wjt endlessos org>
Date:   Tue Aug 16 10:03:08 2022 +0100

    location-entry: refactor handling geocode results
    
    This function is now short enough that I don't think the 'goto out' idiom
    adds any clarity.

 .../pages/timezone/gis-location-entry.c               | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
---
diff --git a/gnome-initial-setup/pages/timezone/gis-location-entry.c 
b/gnome-initial-setup/pages/timezone/gis-location-entry.c
index 53756427..de8fdb88 100644
--- a/gnome-initial-setup/pages/timezone/gis-location-entry.c
+++ b/gnome-initial-setup/pages/timezone/gis-location-entry.c
@@ -803,7 +803,7 @@ _got_places (GObject      *source_object,
     g_autolist(GeocodePlace) places = NULL;
     GisLocationEntry *self = NULL;
     g_autoptr(GError) error = NULL;
-    GtkListStore *store = NULL;
+    g_autoptr(GtkListStore) store = NULL;
     GtkEntryCompletion *completion;
 
     places = geocode_forward_search_finish (GEOCODE_FORWARD (source_object), result, &error);
@@ -820,18 +820,15 @@ _got_places (GObject      *source_object,
         g_debug ("No geocode results, restoring default model");
         gtk_entry_completion_set_match_func (completion, matcher, NULL, NULL);
         gtk_entry_completion_set_model (completion, self->priv->model);
-        goto out;
+    } else {
+        store = gtk_list_store_new (5, G_TYPE_STRING, GEOCODE_TYPE_PLACE, G_TYPE_STRING, G_TYPE_STRING, 
G_TYPE_STRING);
+        gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store),
+                                                 tree_compare_local_name, NULL, NULL);
+        g_list_foreach (places, fill_store, store);
+        gtk_entry_completion_set_match_func (completion, new_matcher, NULL, NULL);
+        gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (store));
     }
 
-    store = gtk_list_store_new (5, G_TYPE_STRING, GEOCODE_TYPE_PLACE, G_TYPE_STRING, G_TYPE_STRING, 
G_TYPE_STRING);
-    gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store),
-                                             tree_compare_local_name, NULL, NULL);
-    g_list_foreach (places, fill_store, store);
-    gtk_entry_completion_set_match_func (completion, new_matcher, NULL, NULL);
-    gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (store));
-    g_object_unref (store);
-
- out:
     g_clear_object (&self->priv->cancellable);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]