[gtranslator/dl-workflow: 7/10] gtr-profile-dialog: Add a new field for auth token




commit 068e154fc462a0657686271b1931accfd369af7d
Author: Amanda Shafack <shafack likhene gmail com>
Date:   Mon Feb 15 22:22:55 2021 +0100

    gtr-profile-dialog: Add a new field for auth token
    
    Users need to be authenticated in order to perform a reserve for
    translation operation or to upload a file. So there is a need to make
    room for authentication.
    
    Add a new field to the profile dialog to store a user's
    authentication token and save the it
    
    Add a tooltip to give more information about the authentication token

 src/gtr-profile-dialog.c  |  9 +++++++++
 src/gtr-profile-dialog.ui | 32 ++++++++++++++++++++++++++++++--
 src/gtr-profile-manager.c |  7 +++++++
 3 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/src/gtr-profile-dialog.c b/src/gtr-profile-dialog.c
index ca4e5256..d27d8387 100644
--- a/src/gtr-profile-dialog.c
+++ b/src/gtr-profile-dialog.c
@@ -40,6 +40,7 @@ typedef struct
   GtkWidget *main_box;
 
   GtkWidget *profile_name;
+  GtkWidget *auth_token;
 
   GtkWidget *author_name;
   GtkWidget *author_email;
@@ -92,6 +93,7 @@ gtr_profile_dialog_init (GtrProfileDialog *dlg)
   priv->main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
   g_object_ref (priv->main_box);
   priv->profile_name = GTK_WIDGET (gtk_builder_get_object (builder, "profile_name"));
+  priv->auth_token = GTK_WIDGET (gtk_builder_get_object (builder, "auth_token"));
   priv->author_name = GTK_WIDGET (gtk_builder_get_object (builder, "name"));
   priv->author_email = GTK_WIDGET (gtk_builder_get_object (builder, "email"));
   priv->team_email = GTK_WIDGET (gtk_builder_get_object (builder, "team_email"));
@@ -114,6 +116,10 @@ fill_entries (GtrProfileDialog *dlg, GtrProfile *profile)
     gtk_entry_set_text (GTK_ENTRY (priv->profile_name),
                         gtr_profile_get_name (profile));
 
+  if (gtr_profile_get_auth_token (profile) != NULL)
+    gtk_entry_set_text (GTK_ENTRY (priv->auth_token),
+                        gtr_profile_get_auth_token (profile));                      
+
   if (gtr_profile_get_author_name (profile) != NULL)
     gtk_entry_set_text (GTK_ENTRY (priv->author_name),
                         gtr_profile_get_author_name (profile));
@@ -191,6 +197,9 @@ gtr_profile_dialog_get_profile (GtrProfileDialog *dlg)
   gtr_profile_set_name (profile,
                         gtk_entry_get_text (GTK_ENTRY (priv->profile_name)));
 
+  gtr_profile_set_auth_token (profile,
+                        gtk_entry_get_text (GTK_ENTRY (priv->auth_token)));
+
   gtr_profile_set_author_name (profile,
                                gtk_entry_get_text (GTK_ENTRY (priv->author_name)));
 
diff --git a/src/gtr-profile-dialog.ui b/src/gtr-profile-dialog.ui
index 417385e1..a3273088 100644
--- a/src/gtr-profile-dialog.ui
+++ b/src/gtr-profile-dialog.ui
@@ -166,6 +166,22 @@
                         <property name="top_attach">5</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkLabel" id="label9">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="label" translatable="yes">_DL auth token</property>
+                        <property name="tooltip_text" translatable="yes">GNOME Damned Lies integration 
token, go to your profile in https://l10n.gnome.org/ to get it</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">auth_token</property>
+                        <property name="xalign">1</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">6</property>
+                      </packing>
+                    </child>
                     <child>
                       <object class="GtkEntry" id="name">
                         <property name="visible">True</property>
@@ -191,6 +207,18 @@
                         <property name="top_attach">4</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkEntry" id="auth_token">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="invisible_char">●</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">6</property>
+                      </packing>
+                    </child>
                     <child>
                       <object class="GtkEntry" id="team_email">
                         <property name="visible">True</property>
@@ -214,7 +242,7 @@
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
-                        <property name="top_attach">6</property>
+                        <property name="top_attach">7</property>
                         <property name="width">2</property>
                       </packing>
                     </child>
@@ -228,7 +256,7 @@
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
-                        <property name="top_attach">7</property>
+                        <property name="top_attach">8</property>
                         <property name="width">2</property>
                       </packing>
                     </child>
diff --git a/src/gtr-profile-manager.c b/src/gtr-profile-manager.c
index 79c11fe4..81eb1286 100644
--- a/src/gtr-profile-manager.c
+++ b/src/gtr-profile-manager.c
@@ -138,6 +138,11 @@ parse_profile (GtrProfileManager *manager,
           content = xmlNodeGetContent (cur);
           gtr_profile_set_name (profile, (const gchar *)content);
         }
+      else if (xmlStrcmp (cur->name, (const xmlChar *)"auth_token") == 0)
+        {
+          content = xmlNodeGetContent (cur);
+          gtr_profile_set_auth_token (profile, (const gchar *)content);
+        }
       else if (xmlStrcmp (cur->name, (const xmlChar *)"author_name") == 0)
         {
           content = xmlNodeGetContent (cur);
@@ -261,6 +266,8 @@ save_profile (GtrProfileManager *manager,
 
   xmlNewTextChild (profile_node, NULL, (const xmlChar *)"profile_name",
                    (const xmlChar *)gtr_profile_get_name (profile));
+  xmlNewTextChild (profile_node, NULL, (const xmlChar *)"auth_token",
+                   (const xmlChar *)gtr_profile_get_auth_token (profile));                
   xmlNewTextChild (profile_node, NULL, (const xmlChar *)"author_name",
                    (const xmlChar *)gtr_profile_get_author_name (profile));
   xmlNewTextChild (profile_node, NULL, (const xmlChar *)"author_email",


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