summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2016-09-06 15:38:46 (GMT)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2016-09-08 13:43:47 (GMT)
commit975e149bf499f2a58201d00d511b7c89c0e32484 (patch)
tree806a2305f104c2e66878b7f93de6161c6bd6d155
parent84ac62bf7dabb84494e9dc7ed080ee5ca0bbe1b1 (diff)
downloadtraprain-975e149bf499f2a58201d00d511b7c89c0e32484.tar.gz
traprain-975e149bf499f2a58201d00d511b7c89c0e32484.tar.xz
client: expose the title as a TrpLanguagesMap
TrpLanguagesMap is part of the API so we can use it directly now. Signed-off-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk> Differential Revision: https://phabricator.apertis.org/D4206
-rw-r--r--tests/test-helper.c10
-rw-r--r--traprain-client/route.c8
-rw-r--r--traprain-client/route.h4
3 files changed, 12 insertions, 10 deletions
diff --git a/tests/test-helper.c b/tests/test-helper.c
index 9e220ab..a8f0d05 100644
--- a/tests/test-helper.c
+++ b/tests/test-helper.c
@@ -10,6 +10,8 @@
#include "test-helper.h"
+#include "traprain-common/languages-map-internal.h"
+
void
build_first_route (TrpRoute *route)
{
@@ -88,7 +90,7 @@ check_client_route (TrpClientRoute *route,
const gchar *title_fr,
guint n_segments)
{
- g_autoptr (GHashTable) titles = NULL;
+ TrpLanguagesMap *titles;
guint nb_title = 0;
g_assert (TRP_CLIENT_IS_ROUTE (route));
@@ -107,11 +109,11 @@ check_client_route (TrpClientRoute *route,
}
titles = trp_client_route_get_titles (route);
- g_assert_cmpuint (g_hash_table_size (titles), ==, nb_title);
+ g_assert_cmpuint (titles->len, ==, nb_title);
if (title_en != NULL)
- g_assert_cmpstr (g_hash_table_lookup (titles, "en_US"), ==, title_en);
+ g_assert_cmpstr (trp_languages_map_lookup (titles, "en_US"), ==, title_en);
if (title_fr != NULL)
- g_assert_cmpstr (g_hash_table_lookup (titles, "fr_FR"), ==, title_fr);
+ g_assert_cmpstr (trp_languages_map_lookup (titles, "fr_FR"), ==, title_fr);
g_assert_cmpuint (trp_client_route_get_n_segments (route), ==, n_segments);
}
diff --git a/traprain-client/route.c b/traprain-client/route.c
index e65a79a..974115e 100644
--- a/traprain-client/route.c
+++ b/traprain-client/route.c
@@ -97,18 +97,16 @@ trp_client_route_get_total_time (TrpClientRoute *self)
* @self: a #TrpClientRoute
*
* Return the human-readable titles of @self in all available languages.
- * The keys of the returned #GHashTable are language codes in the POSIX locale format with locale identifiers
- * defined by ISO 15897, like fr_BE for example. The values are the title in this language.
*
- * Returns: (transfer full) (element-type utf8 utf8) (nullable): the title of @self in all available languages
+ * Returns: (transfer none) (nullable): a #TrpLanguagesMap containing the title of @self in all available languages
* Since: UNRELEASED
*/
-GHashTable *
+TrpLanguagesMap *
trp_client_route_get_titles (TrpClientRoute *self)
{
g_return_val_if_fail (TRP_CLIENT_IS_ROUTE (self), NULL);
- return _trp_languages_map_to_hash (self->title);
+ return self->title;
}
/**
diff --git a/traprain-client/route.h b/traprain-client/route.h
index 81c86f4..0c94c26 100644
--- a/traprain-client/route.h
+++ b/traprain-client/route.h
@@ -14,6 +14,8 @@
#include <gio/gio.h>
#include <glib-object.h>
+#include "traprain-common/languages-map.h"
+
G_BEGIN_DECLS
#define TRP_CLIENT_TYPE_ROUTE (trp_client_route_get_type ())
@@ -21,7 +23,7 @@ G_DECLARE_FINAL_TYPE (TrpClientRoute, trp_client_route, TRP_CLIENT, ROUTE, GObje
guint trp_client_route_get_total_distance (TrpClientRoute *self);
guint trp_client_route_get_total_time (TrpClientRoute *self);
-GHashTable *trp_client_route_get_titles (TrpClientRoute *self);
+TrpLanguagesMap *trp_client_route_get_titles (TrpClientRoute *self);
const gchar *trp_client_route_get_title (TrpClientRoute *self, const gchar *language);
guint trp_client_route_get_n_segments (TrpClientRoute *self);