[gnome-initial-setup/wjt/gweather-4: 8/9] timezone: Renamespace LocationEntry, update to GWeather-4.0
- From: Will Thompson <wjt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/wjt/gweather-4: 8/9] timezone: Renamespace LocationEntry, update to GWeather-4.0
- Date: Tue, 4 Jan 2022 15:06:48 +0000 (UTC)
commit 4ecf4b7de8a8699026fd0730e6698e12d59a2162
Author: Will Thompson <will willthompson co uk>
Date: Tue Jan 4 13:22:11 2022 +0000
timezone: Renamespace LocationEntry, update to GWeather-4.0
Key changes beside renamespacing and a sprinkling of g_auto*:
- GWeatherLocation is an object, not a boxed type.
- _gweather_location_new_detached() is gone, and was never public API anyway. Its
replacement gweather_location_new_detached() accepts slightly different
arguments and in particular performs the nearest-city lookup itself.
https://gitlab.gnome.org/GNOME/gnome-initial-setup/-/issues/132
.../pages/timezone/gis-location-entry.c | 235 ++++++++++-----------
.../pages/timezone/gis-location-entry.h | 48 ++---
gnome-initial-setup/pages/timezone/meson.build | 2 +
3 files changed, 133 insertions(+), 152 deletions(-)
---
diff --git a/gnome-initial-setup/pages/timezone/gis-location-entry.c
b/gnome-initial-setup/pages/timezone/gis-location-entry.c
index d0a4e2b4..c7af2368 100644
--- a/gnome-initial-setup/pages/timezone/gis-location-entry.c
+++ b/gnome-initial-setup/pages/timezone/gis-location-entry.c
@@ -6,22 +6,22 @@
#include "config.h"
-#include "gweather-location-entry.h"
-
-#include "gweather-private.h"
+#include "gis-location-entry.h"
#include <string.h>
+#include <glib/gi18n.h>
#include <gio/gio.h>
#include <geocode-glib/geocode-glib.h>
/**
- * GWeatherLocationEntry:
+ * GisLocationEntry:
*
* A subclass of [class@Gtk.SearchEntry] that provides autocompletion on
* [struct@GWeather.Location]s.
+ *
*/
-struct _GWeatherLocationEntryPrivate {
+struct _GisLocationEntryPrivate {
GWeatherLocation *location;
GWeatherLocation *top;
gboolean show_named_timezones;
@@ -30,7 +30,7 @@ struct _GWeatherLocationEntryPrivate {
GtkTreeModel *model;
};
-G_DEFINE_TYPE_WITH_PRIVATE (GWeatherLocationEntry, gweather_location_entry, GTK_TYPE_SEARCH_ENTRY)
+G_DEFINE_TYPE_WITH_PRIVATE (GisLocationEntry, gis_location_entry, GTK_TYPE_SEARCH_ENTRY)
enum {
PROP_0,
@@ -47,7 +47,7 @@ static void set_property (GObject *object, guint prop_id,
static void get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
-static void set_location_internal (GWeatherLocationEntry *entry,
+static void set_location_internal (GisLocationEntry *entry,
GtkTreeModel *model,
GtkTreeIter *iter,
GWeatherLocation *loc);
@@ -61,20 +61,20 @@ fill_location_entry_model (GtkListStore *store, GWeatherLocation *loc,
enum LOC
{
- LOC_GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME = 0,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCATION,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCAL_SORT_NAME,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME,
- LOC_GWEATHER_LOCATION_ENTRY_COL_ENGLISH_COMPARE_NAME,
- LOC_GWEATHER_LOCATION_ENTRY_NUM_COLUMNS
+ LOC_GIS_LOCATION_ENTRY_COL_DISPLAY_NAME = 0,
+ LOC_GIS_LOCATION_ENTRY_COL_LOCATION,
+ LOC_GIS_LOCATION_ENTRY_COL_LOCAL_SORT_NAME,
+ LOC_GIS_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME,
+ LOC_GIS_LOCATION_ENTRY_COL_ENGLISH_COMPARE_NAME,
+ LOC_GIS_LOCATION_ENTRY_NUM_COLUMNS
};
enum PLACE
{
- PLACE_GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME = 0,
- PLACE_GWEATHER_LOCATION_ENTRY_COL_PLACE,
- PLACE_GWEATHER_LOCATION_ENTRY_COL_LOCAL_SORT_NAME,
- PLACE_GWEATHER_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME
+ PLACE_GIS_LOCATION_ENTRY_COL_DISPLAY_NAME = 0,
+ PLACE_GIS_LOCATION_ENTRY_COL_PLACE,
+ PLACE_GIS_LOCATION_ENTRY_COL_LOCAL_SORT_NAME,
+ PLACE_GIS_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME
};
static gboolean matcher (GtkEntryCompletion *completion, const char *key,
@@ -83,21 +83,21 @@ static gboolean match_selected (GtkEntryCompletion *completion,
GtkTreeModel *model,
GtkTreeIter *iter,
gpointer entry);
-static void entry_changed (GWeatherLocationEntry *entry);
-static void _no_matches (GtkEntryCompletion *completion, GWeatherLocationEntry *entry);
+static void entry_changed (GisLocationEntry *entry);
+static void _no_matches (GtkEntryCompletion *completion, GisLocationEntry *entry);
static void
-gweather_location_entry_init (GWeatherLocationEntry *entry)
+gis_location_entry_init (GisLocationEntry *entry)
{
GtkEntryCompletion *completion;
- GWeatherLocationEntryPrivate *priv;
+ GisLocationEntryPrivate *priv;
- priv = entry->priv = gweather_location_entry_get_instance_private (entry);
+ priv = entry->priv = gis_location_entry_get_instance_private (entry);
completion = gtk_entry_completion_new ();
gtk_entry_completion_set_popup_set_width (completion, FALSE);
- gtk_entry_completion_set_text_column (completion, LOC_GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME);
+ gtk_entry_completion_set_text_column (completion, LOC_GIS_LOCATION_ENTRY_COL_DISPLAY_NAME);
gtk_entry_completion_set_match_func (completion, matcher, NULL, NULL);
gtk_entry_completion_set_inline_completion (completion, TRUE);
@@ -118,29 +118,26 @@ gweather_location_entry_init (GWeatherLocationEntry *entry)
static void
finalize (GObject *object)
{
- GWeatherLocationEntry *entry;
- GWeatherLocationEntryPrivate *priv;
+ GisLocationEntry *entry;
+ GisLocationEntryPrivate *priv;
- entry = GWEATHER_LOCATION_ENTRY (object);
+ entry = GIS_LOCATION_ENTRY (object);
priv = entry->priv;
- if (priv->location)
- gweather_location_unref (priv->location);
- if (priv->top)
- gweather_location_unref (priv->top);
- if (priv->model)
- g_object_unref (priv->model);
+ g_clear_object (&priv->location);
+ g_clear_object (&priv->top);
+ g_clear_object (&priv->model);
- G_OBJECT_CLASS (gweather_location_entry_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gis_location_entry_parent_class)->finalize (object);
}
static void
dispose (GObject *object)
{
- GWeatherLocationEntry *entry;
- GWeatherLocationEntryPrivate *priv;
+ GisLocationEntry *entry;
+ GisLocationEntryPrivate *priv;
- entry = GWEATHER_LOCATION_ENTRY (object);
+ entry = GIS_LOCATION_ENTRY (object);
priv = entry->priv;
if (priv->cancellable) {
@@ -149,7 +146,7 @@ dispose (GObject *object)
priv->cancellable = NULL;
}
- G_OBJECT_CLASS (gweather_location_entry_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gis_location_entry_parent_class)->dispose (object);
}
static int
@@ -161,10 +158,10 @@ tree_compare_local_name (GtkTreeModel *model,
g_autofree gchar *name_a = NULL, *name_b = NULL;
gtk_tree_model_get (model, a,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCAL_SORT_NAME, &name_a,
+ LOC_GIS_LOCATION_ENTRY_COL_LOCAL_SORT_NAME, &name_a,
-1);
gtk_tree_model_get (model, b,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCAL_SORT_NAME, &name_b,
+ LOC_GIS_LOCATION_ENTRY_COL_LOCAL_SORT_NAME, &name_b,
-1);
return g_utf8_collate (name_a, name_b);
@@ -174,11 +171,11 @@ tree_compare_local_name (GtkTreeModel *model,
static void
constructed (GObject *object)
{
- GWeatherLocationEntry *entry;
+ GisLocationEntry *entry;
GtkListStore *store = NULL;
GtkEntryCompletion *completion;
- entry = GWEATHER_LOCATION_ENTRY (object);
+ entry = GIS_LOCATION_ENTRY (object);
if (!entry->priv->top)
entry->priv->top = gweather_location_get_world ();
@@ -193,11 +190,11 @@ constructed (GObject *object)
gtk_entry_completion_set_match_func (completion, matcher, NULL, NULL);
gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (store));
- G_OBJECT_CLASS (gweather_location_entry_parent_class)->constructed (object);
+ G_OBJECT_CLASS (gis_location_entry_parent_class)->constructed (object);
}
static void
-gweather_location_entry_class_init (GWeatherLocationEntryClass *location_entry_class)
+gis_location_entry_class_init (GisLocationEntryClass *location_entry_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (location_entry_class);
@@ -210,7 +207,7 @@ gweather_location_entry_class_init (GWeatherLocationEntryClass *location_entry_c
/* properties */
g_object_class_install_property (
object_class, PROP_TOP,
- g_param_spec_boxed ("top",
+ g_param_spec_object ("top",
"Top Location",
"The GWeatherLocation whose children will be used to fill in the entry",
GWEATHER_TYPE_LOCATION,
@@ -224,7 +221,7 @@ gweather_location_entry_class_init (GWeatherLocationEntryClass *location_entry_c
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (
object_class, PROP_LOCATION,
- g_param_spec_boxed ("location",
+ g_param_spec_object ("location",
"Location",
"The selected GWeatherLocation",
GWEATHER_TYPE_LOCATION,
@@ -235,18 +232,18 @@ static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
- GWeatherLocationEntry *entry = GWEATHER_LOCATION_ENTRY (object);
+ GisLocationEntry *entry = GIS_LOCATION_ENTRY (object);
switch (prop_id) {
case PROP_TOP:
- entry->priv->top = g_value_dup_boxed (value);
+ entry->priv->top = g_value_dup_object (value);
break;
case PROP_SHOW_NAMED_TIMEZONES:
entry->priv->show_named_timezones = g_value_get_boolean (value);
break;
case PROP_LOCATION:
- gweather_location_entry_set_location (GWEATHER_LOCATION_ENTRY (object),
- g_value_get_boxed (value));
+ gis_location_entry_set_location (GIS_LOCATION_ENTRY (object),
+ g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -258,14 +255,14 @@ static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
- GWeatherLocationEntry *entry = GWEATHER_LOCATION_ENTRY (object);
+ GisLocationEntry *entry = GIS_LOCATION_ENTRY (object);
switch (prop_id) {
case PROP_SHOW_NAMED_TIMEZONES:
g_value_set_boolean (value, entry->priv->show_named_timezones);
break;
case PROP_LOCATION:
- g_value_set_boxed (value, entry->priv->location);
+ g_value_set_object (value, entry->priv->location);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -274,7 +271,7 @@ get_property (GObject *object, guint prop_id,
}
static void
-entry_changed (GWeatherLocationEntry *entry)
+entry_changed (GisLocationEntry *entry)
{
GtkEntryCompletion *completion;
const gchar *text;
@@ -300,31 +297,30 @@ entry_changed (GWeatherLocationEntry *entry)
}
static void
-set_location_internal (GWeatherLocationEntry *entry,
+set_location_internal (GisLocationEntry *entry,
GtkTreeModel *model,
GtkTreeIter *iter,
GWeatherLocation *loc)
{
- GWeatherLocationEntryPrivate *priv;
+ GisLocationEntryPrivate *priv;
char *name;
priv = entry->priv;
- if (priv->location)
- gweather_location_unref (priv->location);
+ g_clear_object (&priv->location);
g_assert (iter == NULL || loc == NULL);
if (iter) {
gtk_tree_model_get (model, iter,
- LOC_GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME, &name,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCATION, &priv->location,
+ LOC_GIS_LOCATION_ENTRY_COL_DISPLAY_NAME, &name,
+ LOC_GIS_LOCATION_ENTRY_COL_LOCATION, &priv->location,
-1);
gtk_entry_set_text (GTK_ENTRY (entry), name);
priv->custom_text = FALSE;
g_free (name);
} else if (loc) {
- priv->location = gweather_location_ref (loc);
+ priv->location = g_object_ref (loc);
gtk_entry_set_text (GTK_ENTRY (entry), gweather_location_get_name (loc));
priv->custom_text = FALSE;
} else {
@@ -338,8 +334,8 @@ set_location_internal (GWeatherLocationEntry *entry,
}
/**
- * gweather_location_entry_set_location:
- * @entry: a #GWeatherLocationEntry
+ * gis_location_entry_set_location:
+ * @entry: a #GisLocationEntry
* @loc: (allow-none): a #GWeatherLocation in @entry, or %NULL to
* clear @entry
*
@@ -349,15 +345,15 @@ set_location_internal (GWeatherLocationEntry *entry,
* equal to @loc, that will be chosen in place of @loc.
**/
void
-gweather_location_entry_set_location (GWeatherLocationEntry *entry,
+gis_location_entry_set_location (GisLocationEntry *entry,
GWeatherLocation *loc)
{
GtkEntryCompletion *completion;
GtkTreeModel *model;
GtkTreeIter iter;
- GWeatherLocation *cmploc;
+ g_autoptr(GWeatherLocation) cmploc = NULL;
- g_return_if_fail (GWEATHER_IS_LOCATION_ENTRY (entry));
+ g_return_if_fail (GIS_IS_LOCATION_ENTRY (entry));
completion = gtk_entry_get_completion (GTK_ENTRY (entry));
model = gtk_entry_completion_get_model (completion);
@@ -370,64 +366,63 @@ gweather_location_entry_set_location (GWeatherLocationEntry *entry,
gtk_tree_model_get_iter_first (model, &iter);
do {
gtk_tree_model_get (model, &iter,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCATION, &cmploc,
+ LOC_GIS_LOCATION_ENTRY_COL_LOCATION, &cmploc,
-1);
if (gweather_location_equal (loc, cmploc)) {
set_location_internal (entry, model, &iter, NULL);
- gweather_location_unref (cmploc);
return;
}
- gweather_location_unref (cmploc);
+ g_clear_object (&cmploc);
} while (gtk_tree_model_iter_next (model, &iter));
set_location_internal (entry, model, NULL, loc);
}
/**
- * gweather_location_entry_get_location:
- * @entry: a #GWeatherLocationEntry
+ * gis_location_entry_get_location:
+ * @entry: a #GisLocationEntry
*
* Gets the location that was set by a previous call to
- * gweather_location_entry_set_location() or was selected by the user.
+ * gis_location_entry_set_location() or was selected by the user.
*
* Return value: (transfer full) (allow-none): the selected location
* (which you must unref when you are done with it), or %NULL if no
* location is selected.
**/
GWeatherLocation *
-gweather_location_entry_get_location (GWeatherLocationEntry *entry)
+gis_location_entry_get_location (GisLocationEntry *entry)
{
- g_return_val_if_fail (GWEATHER_IS_LOCATION_ENTRY (entry), NULL);
+ g_return_val_if_fail (GIS_IS_LOCATION_ENTRY (entry), NULL);
if (entry->priv->location)
- return gweather_location_ref (entry->priv->location);
+ return g_object_ref (entry->priv->location);
else
return NULL;
}
/**
- * gweather_location_entry_has_custom_text:
- * @entry: a #GWeatherLocationEntry
+ * gis_location_entry_has_custom_text:
+ * @entry: a #GisLocationEntry
*
* Checks whether or not @entry's text has been modified by the user.
* Note that this does not mean that no location is associated with @entry.
- * gweather_location_entry_get_location() should be used for this.
+ * gis_location_entry_get_location() should be used for this.
*
* Return value: %TRUE if @entry's text was modified by the user, or %FALSE if
* it's set to the default text of a location.
**/
gboolean
-gweather_location_entry_has_custom_text (GWeatherLocationEntry *entry)
+gis_location_entry_has_custom_text (GisLocationEntry *entry)
{
- g_return_val_if_fail (GWEATHER_IS_LOCATION_ENTRY (entry), FALSE);
+ g_return_val_if_fail (GIS_IS_LOCATION_ENTRY (entry), FALSE);
return entry->priv->custom_text;
}
/**
- * gweather_location_entry_set_city:
- * @entry: a #GWeatherLocationEntry
+ * gis_location_entry_set_city:
+ * @entry: a #GisLocationEntry
* @city_name: (allow-none): the city name, or %NULL
* @code: the METAR station code
*
@@ -439,18 +434,16 @@ gweather_location_entry_has_custom_text (GWeatherLocationEntry *entry)
* %FALSE otherwise.
**/
gboolean
-gweather_location_entry_set_city (GWeatherLocationEntry *entry,
+gis_location_entry_set_city (GisLocationEntry *entry,
const char *city_name,
const char *code)
{
GtkEntryCompletion *completion;
GtkTreeModel *model;
GtkTreeIter iter;
- GWeatherLocation *cmploc;
const char *cmpcode;
- char *cmpname;
- g_return_val_if_fail (GWEATHER_IS_LOCATION_ENTRY (entry), FALSE);
+ g_return_val_if_fail (GIS_IS_LOCATION_ENTRY (entry), FALSE);
g_return_val_if_fail (code != NULL, FALSE);
completion = gtk_entry_get_completion (GTK_ENTRY (entry));
@@ -458,28 +451,24 @@ gweather_location_entry_set_city (GWeatherLocationEntry *entry,
gtk_tree_model_get_iter_first (model, &iter);
do {
+ g_autoptr(GWeatherLocation) cmploc = NULL;
gtk_tree_model_get (model, &iter,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCATION, &cmploc,
+ LOC_GIS_LOCATION_ENTRY_COL_LOCATION, &cmploc,
-1);
cmpcode = gweather_location_get_code (cmploc);
if (!cmpcode || strcmp (cmpcode, code) != 0) {
- gweather_location_unref (cmploc);
continue;
}
if (city_name) {
- cmpname = gweather_location_get_city_name (cmploc);
+ g_autofree gchar *cmpname = gweather_location_get_city_name (cmploc);
if (!cmpname || strcmp (cmpname, city_name) != 0) {
- gweather_location_unref (cmploc);
- g_free (cmpname);
continue;
}
- g_free (cmpname);
}
set_location_internal (entry, model, &iter, NULL);
- gweather_location_unref (cmploc);
return TRUE;
} while (gtk_tree_model_iter_next (model, &iter));
@@ -569,11 +558,11 @@ fill_location_entry_model (GtkListStore *store, GWeatherLocation *loc,
gweather_location_get_english_sort_name (loc),
parent_compare_english_name);
gtk_list_store_insert_with_values (store, NULL, -1,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCATION, loc,
- LOC_GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME, display_name,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCAL_SORT_NAME, local_sort_name,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME,
local_compare_name,
- LOC_GWEATHER_LOCATION_ENTRY_COL_ENGLISH_COMPARE_NAME,
english_compare_name,
+ LOC_GIS_LOCATION_ENTRY_COL_LOCATION, loc,
+ LOC_GIS_LOCATION_ENTRY_COL_DISPLAY_NAME, display_name,
+ LOC_GIS_LOCATION_ENTRY_COL_LOCAL_SORT_NAME, local_sort_name,
+ LOC_GIS_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME, local_compare_name,
+ LOC_GIS_LOCATION_ENTRY_COL_ENGLISH_COMPARE_NAME,
english_compare_name,
-1);
g_free (display_name);
@@ -584,11 +573,11 @@ fill_location_entry_model (GtkListStore *store, GWeatherLocation *loc,
case GWEATHER_LOCATION_NAMED_TIMEZONE:
if (show_named_timezones) {
gtk_list_store_insert_with_values (store, NULL, -1,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCATION, loc,
- LOC_GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME,
gweather_location_get_name (loc),
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCAL_SORT_NAME,
gweather_location_get_sort_name (loc),
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME,
gweather_location_get_sort_name (loc),
- LOC_GWEATHER_LOCATION_ENTRY_COL_ENGLISH_COMPARE_NAME,
gweather_location_get_english_sort_name (loc),
+ LOC_GIS_LOCATION_ENTRY_COL_LOCATION, loc,
+ LOC_GIS_LOCATION_ENTRY_COL_DISPLAY_NAME,
gweather_location_get_name (loc),
+ LOC_GIS_LOCATION_ENTRY_COL_LOCAL_SORT_NAME,
gweather_location_get_sort_name (loc),
+ LOC_GIS_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME,
gweather_location_get_sort_name (loc),
+ LOC_GIS_LOCATION_ENTRY_COL_ENGLISH_COMPARE_NAME,
gweather_location_get_english_sort_name (loc),
-1);
}
break;
@@ -689,8 +678,8 @@ matcher (GtkEntryCompletion *completion, const char *key,
gboolean match;
gtk_tree_model_get (gtk_entry_completion_get_model (completion), iter,
- LOC_GWEATHER_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME, &local_compare_name,
- LOC_GWEATHER_LOCATION_ENTRY_COL_ENGLISH_COMPARE_NAME, &english_compare_name,
+ LOC_GIS_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME, &local_compare_name,
+ LOC_GIS_LOCATION_ENTRY_COL_ENGLISH_COMPARE_NAME, &english_compare_name,
-1);
match = match_compare_name (key, local_compare_name) ||
@@ -708,9 +697,9 @@ match_selected (GtkEntryCompletion *completion,
GtkTreeIter *iter,
gpointer entry)
{
- GWeatherLocationEntryPrivate *priv;
+ GisLocationEntryPrivate *priv;
- priv = ((GWeatherLocationEntry *)entry)->priv;
+ priv = ((GisLocationEntry *)entry)->priv;
if (model != priv->model) {
GeocodePlace *place;
@@ -721,8 +710,8 @@ match_selected (GtkEntryCompletion *completion,
const char* country_code;
gtk_tree_model_get (model, iter,
- PLACE_GWEATHER_LOCATION_ENTRY_COL_PLACE, &place,
- PLACE_GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME, &display_name,
+ PLACE_GIS_LOCATION_ENTRY_COL_PLACE, &place,
+ PLACE_GIS_LOCATION_ENTRY_COL_DISPLAY_NAME, &display_name,
-1);
country_code = geocode_place_get_country_code (place);
@@ -732,15 +721,15 @@ match_selected (GtkEntryCompletion *completion,
scope = priv->top;
loc = geocode_place_get_location (place);
- location = gweather_location_find_nearest_city (scope, geocode_location_get_latitude (loc),
geocode_location_get_longitude (loc));
-
- location = _gweather_location_new_detached (location, display_name, TRUE,
- geocode_location_get_latitude (loc) * M_PI / 180.0,
- geocode_location_get_longitude (loc) * M_PI / 180.0);
+ location = gweather_location_new_detached (display_name,
+ NULL,
+ geocode_location_get_latitude (loc),
+ geocode_location_get_longitude (loc));
set_location_internal (entry, model, NULL, location);
g_object_unref (place);
+ g_object_unref (location);
g_free (display_name);
} else {
set_location_internal (entry, model, iter, NULL);
@@ -769,10 +758,10 @@ fill_store (gpointer data, gpointer user_data)
compare_name = g_utf8_casefold (normalized, -1);
gtk_list_store_insert_with_values (user_data, NULL, -1,
- PLACE_GWEATHER_LOCATION_ENTRY_COL_PLACE, place,
- PLACE_GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME, display_name,
- PLACE_GWEATHER_LOCATION_ENTRY_COL_LOCAL_SORT_NAME, compare_name,
- PLACE_GWEATHER_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME, compare_name,
+ PLACE_GIS_LOCATION_ENTRY_COL_PLACE, place,
+ PLACE_GIS_LOCATION_ENTRY_COL_DISPLAY_NAME, display_name,
+ PLACE_GIS_LOCATION_ENTRY_COL_LOCAL_SORT_NAME, compare_name,
+ PLACE_GIS_LOCATION_ENTRY_COL_LOCAL_COMPARE_NAME, compare_name,
-1);
g_free (normalized);
@@ -785,7 +774,7 @@ _got_places (GObject *source_object,
gpointer user_data)
{
GList *places;
- GWeatherLocationEntry *self = user_data;
+ GisLocationEntry *self = user_data;
GError *error = NULL;
GtkListStore *store = NULL;
GtkEntryCompletion *completion;
@@ -821,7 +810,7 @@ _got_places (GObject *source_object,
}
static void
-_no_matches (GtkEntryCompletion *completion, GWeatherLocationEntry *entry) {
+_no_matches (GtkEntryCompletion *completion, GisLocationEntry *entry) {
const gchar *key = gtk_entry_get_text(GTK_ENTRY (entry));
GeocodeForward *forward;
@@ -840,21 +829,21 @@ _no_matches (GtkEntryCompletion *completion, GWeatherLocationEntry *entry) {
}
/**
- * gweather_location_entry_new:
+ * gis_location_entry_new:
* @top: the top-level location for the entry.
*
- * Creates a new #GWeatherLocationEntry.
+ * Creates a new #GisLocationEntry.
*
* @top will normally be the location returned from
* gweather_location_get_world(), but you can create an entry that
* only accepts a smaller set of locations if you want.
*
- * Return value: the new #GWeatherLocationEntry
+ * Return value: the new #GisLocationEntry
**/
GtkWidget *
-gweather_location_entry_new (GWeatherLocation *top)
+gis_location_entry_new (GWeatherLocation *top)
{
- return g_object_new (GWEATHER_TYPE_LOCATION_ENTRY,
+ return g_object_new (GIS_TYPE_LOCATION_ENTRY,
"top", top,
NULL);
}
diff --git a/gnome-initial-setup/pages/timezone/gis-location-entry.h
b/gnome-initial-setup/pages/timezone/gis-location-entry.h
index ccd606c7..32fed2e5 100644
--- a/gnome-initial-setup/pages/timezone/gis-location-entry.h
+++ b/gnome-initial-setup/pages/timezone/gis-location-entry.h
@@ -6,51 +6,41 @@
#pragma once
-#if !(defined(IN_GWEATHER_H) || defined(GWEATHER_COMPILATION))
-#error "gweather-location-entry.h must not be included individually, include gweather.h instead"
-#endif
-
#include <gtk/gtk.h>
-#include <libgweather/gweather-location.h>
+#include <libgweather/gweather.h>
G_BEGIN_DECLS
-typedef struct _GWeatherLocationEntry GWeatherLocationEntry;
-typedef struct _GWeatherLocationEntryClass GWeatherLocationEntryClass;
-typedef struct _GWeatherLocationEntryPrivate GWeatherLocationEntryPrivate;
+typedef struct _GisLocationEntry GisLocationEntry;
+typedef struct _GisLocationEntryClass GisLocationEntryClass;
+typedef struct _GisLocationEntryPrivate GisLocationEntryPrivate;
-#define GWEATHER_TYPE_LOCATION_ENTRY (gweather_location_entry_get_type ())
-#define GWEATHER_LOCATION_ENTRY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object),
GWEATHER_TYPE_LOCATION_ENTRY, GWeatherLocationEntry))
-#define GWEATHER_LOCATION_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GWEATHER_TYPE_LOCATION_ENTRY, GWeatherLocationEntryClass))
-#define GWEATHER_IS_LOCATION_ENTRY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object),
GWEATHER_TYPE_LOCATION_ENTRY))
-#define GWEATHER_IS_LOCATION_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GWEATHER_TYPE_LOCATION_ENTRY))
-#define GWEATHER_LOCATION_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GWEATHER_TYPE_LOCATION_ENTRY, GWeatherLocationEntryClass))
+#define GIS_TYPE_LOCATION_ENTRY (gis_location_entry_get_type ())
+#define GIS_LOCATION_ENTRY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GIS_TYPE_LOCATION_ENTRY,
GisLocationEntry))
+#define GIS_LOCATION_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIS_TYPE_LOCATION_ENTRY,
GisLocationEntryClass))
+#define GIS_IS_LOCATION_ENTRY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GIS_TYPE_LOCATION_ENTRY))
+#define GIS_IS_LOCATION_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIS_TYPE_LOCATION_ENTRY))
+#define GIS_LOCATION_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIS_TYPE_LOCATION_ENTRY,
GisLocationEntryClass))
-struct _GWeatherLocationEntry {
+struct _GisLocationEntry {
GtkSearchEntry parent;
/*< private >*/
- GWeatherLocationEntryPrivate *priv;
+ GisLocationEntryPrivate *priv;
};
-struct _GWeatherLocationEntryClass {
+struct _GisLocationEntryClass {
GtkSearchEntryClass parent_class;
};
-GWEATHER_AVAILABLE_IN_ALL
-GType gweather_location_entry_get_type (void);
+GType gis_location_entry_get_type (void);
-GWEATHER_AVAILABLE_IN_ALL
-GtkWidget * gweather_location_entry_new (GWeatherLocation *top);
-GWEATHER_AVAILABLE_IN_ALL
-void gweather_location_entry_set_location (GWeatherLocationEntry *entry,
+GtkWidget * gis_location_entry_new (GWeatherLocation *top);
+void gis_location_entry_set_location (GisLocationEntry *entry,
GWeatherLocation *loc);
-GWEATHER_AVAILABLE_IN_ALL
-GWeatherLocation * gweather_location_entry_get_location (GWeatherLocationEntry *entry);
-GWEATHER_AVAILABLE_IN_ALL
-gboolean gweather_location_entry_has_custom_text (GWeatherLocationEntry *entry);
-GWEATHER_AVAILABLE_IN_ALL
-gboolean gweather_location_entry_set_city (GWeatherLocationEntry *entry,
+GWeatherLocation * gis_location_entry_get_location (GisLocationEntry *entry);
+gboolean gis_location_entry_has_custom_text (GisLocationEntry *entry);
+gboolean gis_location_entry_set_city (GisLocationEntry *entry,
const char *city_name,
const char *code);
diff --git a/gnome-initial-setup/pages/timezone/meson.build b/gnome-initial-setup/pages/timezone/meson.build
index 1c4853d2..04c2f922 100644
--- a/gnome-initial-setup/pages/timezone/meson.build
+++ b/gnome-initial-setup/pages/timezone/meson.build
@@ -23,6 +23,8 @@ sources += files(
'tz.h',
'gis-bubble-widget.c',
'gis-bubble-widget.h',
+ 'gis-location-entry.c',
+ 'gis-location-entry.h',
'gis-timezone-page.c',
'gis-timezone-page.h'
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]