[gnome-initial-setup] software: Revise strings once more



commit e329601458eb20c02512b20d3b0637d9f9858919
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Aug 30 16:42:55 2016 +0200

    software: Revise strings once more
    
    Use the OS vendor name from /etc/os-release, and tweak the strings
    following the latest mockup by Allan.

 .../pages/software/gis-software-page.c             |   72 +++++++++++++++++++-
 .../pages/software/gis-software-page.ui            |    8 +--
 2 files changed, 74 insertions(+), 6 deletions(-)
---
diff --git a/gnome-initial-setup/pages/software/gis-software-page.c 
b/gnome-initial-setup/pages/software/gis-software-page.c
index aea7405..4908613 100644
--- a/gnome-initial-setup/pages/software/gis-software-page.c
+++ b/gnome-initial-setup/pages/software/gis-software-page.c
@@ -35,12 +35,76 @@ struct _GisSoftwarePagePrivate
 {
   GtkWidget *more_popover;
   GtkWidget *proprietary_switch;
+  GtkWidget *text_label;
 };
 
 typedef struct _GisSoftwarePagePrivate GisSoftwarePagePrivate;
 
 G_DEFINE_TYPE_WITH_PRIVATE (GisSoftwarePage, gis_software_page, GIS_TYPE_PAGE);
 
+static char *
+get_item (const char *buffer, const char *name)
+{
+  char *label, *start, *end, *result;
+  char end_char;
+
+  result = NULL;
+  start = NULL;
+  end = NULL;
+  label = g_strconcat (name, "=", NULL);
+  if ((start = strstr (buffer, label)) != NULL)
+    {
+      start += strlen (label);
+      end_char = '\n';
+      if (*start == '"')
+        {
+          start++;
+          end_char = '"';
+        }
+
+      end = strchr (start, end_char);
+    }
+
+    if (start != NULL && end != NULL)
+      {
+        result = g_strndup (start, end - start);
+      }
+
+  g_free (label);
+
+  return result;
+}
+
+static void
+update_distro_name (GisSoftwarePage *page)
+{
+  GisSoftwarePagePrivate *priv = gis_software_page_get_instance_private (page);
+  char *buffer;
+  char *name;
+  char *text;
+
+  name = NULL;
+
+  if (g_file_get_contents ("/etc/os-release", &buffer, NULL, NULL))
+    {
+      name = get_item (buffer, "NAME");
+      g_free (buffer);
+    }
+
+  if (!name)
+    name = g_strdup ("GNOME");
+
+  /* Translators: the parameter here is the name of a distribution,
+   * like "Fedora" or "Ubuntu". It falls back to "GNOME" if we can't
+   * detect any distribution.
+   */
+  text = g_strdup_printf (_("Proprietary software sources provide access to additional software, including 
web browsers and games. This software typically has restrictions on use and access to source code, and is not 
provided by %s."), name);
+  gtk_label_set_label (GTK_LABEL (priv->text_label), text);
+  g_free (text);
+
+  g_free (name);
+}
+
 static void
 gis_software_page_constructed (GObject *object)
 {
@@ -49,6 +113,10 @@ gis_software_page_constructed (GObject *object)
 
   G_OBJECT_CLASS (gis_software_page_parent_class)->constructed (object);
 
+  update_distro_name (page);
+
+  gis_page_set_complete (GIS_PAGE (page), TRUE);
+
   gtk_widget_show (GTK_WIDGET (page));
 }
 
@@ -64,7 +132,8 @@ gis_software_page_dispose (GObject *object)
 static void
 gis_software_page_locale_changed (GisPage *page)
 {
-  gis_page_set_title (GIS_PAGE (page), _("Software Sources"));
+  gis_page_set_title (page, _("Software Sources"));
+  update_distro_name (GIS_SOFTWARE_PAGE (page));
 }
 
 static gboolean
@@ -99,6 +168,7 @@ gis_software_page_class_init (GisSoftwarePageClass *klass)
   gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), 
"/org/gnome/initial-setup/gis-software-page.ui");
   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisSoftwarePage, more_popover);
   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisSoftwarePage, 
proprietary_switch);
+  gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisSoftwarePage, text_label);
   gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), activate_link);
   gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), state_set);
 
diff --git a/gnome-initial-setup/pages/software/gis-software-page.ui 
b/gnome-initial-setup/pages/software/gis-software-page.ui
index 5b27464..3932e73 100644
--- a/gnome-initial-setup/pages/software/gis-software-page.ui
+++ b/gnome-initial-setup/pages/software/gis-software-page.ui
@@ -2,7 +2,6 @@
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
   <template class="GisSoftwarePage" parent="GisPage">
-    <property name="complete">True</property>
     <child>
       <object class="GtkBox" id="box">
         <property name="visible">True</property>
@@ -37,14 +36,13 @@
           </object>
         </child>
         <child>
-          <object class="GtkLabel">
+          <object class="GtkLabel" id="text_label">
             <property name="visible">True</property>
             <property name="margin-top">40</property>
             <property name="xalign">0.5</property>
             <property name="justify">center</property>
-            <property name="max-width-chars">50</property>
+            <property name="max-width-chars">65</property>
             <property name="wrap">True</property>
-            <property name="label" translatable="yes">Proprietary software sources provide access to 
additional software, including web browsers and games. This software typically has restrictions on use and 
access to source code.</property>
           </object>
         </child>
         <child>
@@ -164,7 +162,7 @@
             <property name="margin-bottom">10</property>
             <property name="wrap">True</property>
             <property name="xalign">0</property>
-            <property name="label" translatable="yes">Proprietary software typically has restrictions on how 
it can be used and on access to its source code. This prevents anyone but the software owner from inspecting, 
improving or learning from its code.</property>
+            <property name="label" translatable="yes">Proprietary software typically has restrictions on how 
it can be used and on access to source code. This prevents anyone but the software owner from inspecting, 
improving or learning from its code.</property>
           </object>
         </child>
         <child>


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