[gtranslator] dl: Autoselect language team



commit 5b8991c29a0602aa4581b3ca7061c0cc2bd5fab0
Author: Daniel GarcĂ­a Moreno <dani danigm net>
Date:   Sat Sep 28 10:03:11 2019 +0200

    dl: Autoselect language team
    
    Autoselect language team using the default profile.
    
    Fix: https://gitlab.gnome.org/GNOME/gtranslator/issues/67

 src/gtr-dl-teams.c         | 10 ++++++++++
 src/gtr-filter-selection.c |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/src/gtr-dl-teams.c b/src/gtr-dl-teams.c
index a4cf8164..0d2286aa 100644
--- a/src/gtr-dl-teams.c
+++ b/src/gtr-dl-teams.c
@@ -25,6 +25,7 @@
 #include "gtr-filter-selection.h"
 #include "gtr-window.h"
 #include "gtr-utils.h"
+#include "gtr-profile-manager.h"
 #include <libsoup/soup.h>
 
 #include <json-glib/json-glib.h>
@@ -107,6 +108,9 @@ gtr_dl_teams_parse_teams_json (GObject *object,
 {
   g_autoptr(JsonParser) parser = json_parser_new ();
   g_autoptr(GInputStream) stream = NULL;
+  GtrProfileManager * pmanager = NULL;
+  const char *def_lang = NULL;
+  GtrProfile *profile = NULL;
   GError *error = NULL;
   JsonNode *node = NULL;
   JsonArray *array = NULL;
@@ -139,12 +143,18 @@ gtr_dl_teams_parse_teams_json (GObject *object,
   node = json_parser_get_root (parser);
   array = json_node_get_array (node);
 
+  pmanager = gtr_profile_manager_get_default ();
+  profile = gtr_profile_manager_get_active_profile (pmanager);
+  def_lang = gtr_profile_get_language_code (profile);
+
   /* Fill teams list store with values from JSON and set store as combo box model */
   json_array_foreach_element (array, gtr_dl_teams_list_add, &options);
   gtr_filter_selection_set_options_full (GTR_FILTER_SELECTION (priv->teams_combobox), options);
+  gtr_filter_selection_set_option (GTR_FILTER_SELECTION (priv->teams_combobox), def_lang);
 
   /* Enable selection */
   gtk_widget_set_sensitive (priv->teams_combobox, TRUE);
+  g_object_unref (pmanager);
 }
 
 static void
diff --git a/src/gtr-filter-selection.c b/src/gtr-filter-selection.c
index ca78d533..73235e1c 100644
--- a/src/gtr-filter-selection.c
+++ b/src/gtr-filter-selection.c
@@ -175,7 +175,7 @@ gtr_filter_selection_set_option (GtrFilterSelection *self,
   for (o = priv->options; o != NULL; o = g_slist_next (o))
     {
       GtrFilterOption *opt = (GtrFilterOption *)o->data;
-      if (!g_strcmp0 (opt->desc, name))
+      if (!g_strcmp0 (opt->name, name) || !g_strcmp0 (opt->desc, name))
         {
           gtr_filter_selection_set_option_full (self, opt);
           break;


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