[gnome-initial-setup/shell/4765: 289/362] endless-eula: show terms and conditions inline
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/shell/4765: 289/362] endless-eula: show terms and conditions inline
- Date: Thu, 19 Mar 2015 01:45:22 +0000 (UTC)
commit 8e825d9f311b6b4cda0b68a8fd2b8e15640baf3a
Author: Cosimo Cecchi <cosimo endlessm com>
Date: Tue Dec 2 15:56:38 2014 -0800
endless-eula: show terms and conditions inline
We use an EvView from the Evince library for this purpose.
[endlessm/eos-shell#3601]
configure.ac | 4 +-
gnome-initial-setup/gnome-initial-setup.c | 4 +
.../pages/endless-eula/endless-eula-page.css | 7 +
.../pages/endless-eula/endless-eula.gresource.xml | 1 +
.../pages/endless-eula/gis-endless-eula-page.c | 122 ++++++++++++++
.../pages/endless-eula/gis-endless-eula-page.ui | 166 +++++++-------------
6 files changed, 191 insertions(+), 113 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 507c22c..8a4ea78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,7 +53,9 @@ PKG_CHECK_MODULES(INITIAL_SETUP,
pango >= $PANGO_REQUIRED_VERSION
pwquality
egg-list-box-uninstalled
- libsecret-1)
+ libsecret-1
+ evince-view-3.0
+ evince-document-3.0)
PKG_CHECK_MODULES(COPY_WORKER, gio-2.0 gnome-keyring-1)
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index 478ba74..29385b3 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -29,6 +29,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <glib/gi18n.h>
+#include <evince-document.h>
#ifdef HAVE_CLUTTER
#include <clutter-gtk/clutter-gtk.h>
@@ -265,6 +266,7 @@ main (int argc, char *argv[])
#endif
gtk_init (&argc, &argv);
+ ev_init ();
#if HAVE_CLUTTER
if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS) {
@@ -282,6 +284,8 @@ main (int argc, char *argv[])
g_object_unref (driver);
g_option_context_free (context);
+ ev_shutdown ();
+
return status;
}
diff --git a/gnome-initial-setup/pages/endless-eula/endless-eula-page.css
b/gnome-initial-setup/pages/endless-eula/endless-eula-page.css
new file mode 100644
index 0000000..deef1af
--- /dev/null
+++ b/gnome-initial-setup/pages/endless-eula/endless-eula-page.css
@@ -0,0 +1,7 @@
+EvView.document-page {
+ border-width: 0;
+ padding: 0;
+ border-image: none;
+ background-color: white;
+ background-image: none;
+}
diff --git a/gnome-initial-setup/pages/endless-eula/endless-eula.gresource.xml
b/gnome-initial-setup/pages/endless-eula/endless-eula.gresource.xml
index c4d146e..1705d90 100644
--- a/gnome-initial-setup/pages/endless-eula/endless-eula.gresource.xml
+++ b/gnome-initial-setup/pages/endless-eula/endless-eula.gresource.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/initial-setup">
+ <file alias="endless-eula-page.css">endless-eula-page.css</file>
<file preprocess="xml-stripblanks" alias="gis-endless-eula-page.ui">gis-endless-eula-page.ui</file>
</gresource>
</gresources>
diff --git a/gnome-initial-setup/pages/endless-eula/gis-endless-eula-page.c
b/gnome-initial-setup/pages/endless-eula/gis-endless-eula-page.c
index 9a1ad84..efcfe97 100644
--- a/gnome-initial-setup/pages/endless-eula/gis-endless-eula-page.c
+++ b/gnome-initial-setup/pages/endless-eula/gis-endless-eula-page.c
@@ -30,6 +30,8 @@
#include "endless-eula-resources.h"
+#include <evince-view.h>
+#include <evince-document.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
@@ -145,6 +147,123 @@ gis_endless_eula_page_finalize (GObject *object)
G_OBJECT_CLASS (gis_endless_eula_page_parent_class)->finalize (object);
}
+static GFile *
+get_terms_document (void)
+{
+ const gchar * const * languages;
+ const gchar * const * data_dirs;
+ const gchar *language;
+ gchar *path = NULL;
+ gint i, j;
+ gboolean found = FALSE;
+ GFile *file;
+
+ data_dirs = g_get_system_data_dirs ();
+ languages = g_get_language_names ();
+ path = NULL;
+
+ for (i = 0; languages[i] != NULL; i++)
+ {
+ language = languages[i];
+
+ for (j = 0; data_dirs[j] != NULL; j++)
+ {
+ path = g_build_filename (data_dirs[j],
+ "eos-license-service",
+ "terms",
+ language,
+ "Endless-Mobile-Terms-of-Use.pdf",
+ NULL);
+
+ if (g_file_test (path, G_FILE_TEST_EXISTS))
+ {
+ found = TRUE;
+ break;
+ }
+
+ g_free (path);
+ path = NULL;
+ }
+
+ if (found)
+ break;
+ }
+
+ if (!found)
+ {
+ g_critical ("Unable to find terms and conditions PDF on the system");
+ return NULL;
+ }
+
+ file = g_file_new_for_path (path);
+ g_free (path);
+
+ return file;
+}
+
+static void
+load_terms_view (GisEndlessEulaPage *page)
+{
+ EvDocument *document;
+ EvDocumentModel *model;
+ GFile *file;
+ GtkWidget *widget, *view;
+ GError *error = NULL;
+
+ file = get_terms_document ();
+ if (file == NULL)
+ return;
+
+ document = ev_document_factory_get_document_for_gfile (file,
+ EV_DOCUMENT_LOAD_FLAG_NONE,
+ NULL,
+ &error);
+ g_object_unref (file);
+
+ if (error != NULL)
+ {
+ g_critical ("Unable to load terms and conditions PDF: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ model = ev_document_model_new_with_document (document);
+ view = ev_view_new ();
+ ev_view_set_model (EV_VIEW (view), model);
+
+ widget = WID ("eula-scrolledwin");
+ gtk_container_add (GTK_CONTAINER (widget), view);
+ gtk_widget_show (view);
+}
+
+static void
+load_css_overrides (GisEndlessEulaPage *page)
+{
+ GtkCssProvider *provider;
+ GFile *file;
+ GError *error = NULL;
+
+ provider = gtk_css_provider_new ();
+ file = g_file_new_for_uri ("resource:///org/gnome/initial-setup/endless-eula-page.css");
+ gtk_css_provider_load_from_file (provider, file, &error);
+ g_object_unref (file);
+
+ if (error != NULL)
+ {
+ g_warning ("Unable to load CSS overrides for the endless-eula page: %s",
+ error->message);
+ g_error_free (error);
+ }
+ else
+ {
+ gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (GTK_WIDGET (page)),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+
+ g_object_unref (provider);
+}
+
static void
gis_endless_eula_page_constructed (GObject *object)
{
@@ -169,6 +288,8 @@ gis_endless_eula_page_constructed (GObject *object)
g_error_free (error);
}
+ load_css_overrides (page);
+
gtk_container_add (GTK_CONTAINER (page), WID ("endless-eula-page"));
gtk_widget_show (GTK_WIDGET (page));
@@ -181,6 +302,7 @@ gis_endless_eula_page_constructed (GObject *object)
G_CALLBACK (metrics_privacy_label_link_cb), page);
sync_metrics_active_state (page);
+ load_terms_view (page);
gis_page_set_forward_text (GIS_PAGE (page), _("_Accept and continue"));
gis_page_set_complete (GIS_PAGE (page), TRUE);
diff --git a/gnome-initial-setup/pages/endless-eula/gis-endless-eula-page.ui
b/gnome-initial-setup/pages/endless-eula/gis-endless-eula-page.ui
index 6700705..259825d 100644
--- a/gnome-initial-setup/pages/endless-eula/gis-endless-eula-page.ui
+++ b/gnome-initial-setup/pages/endless-eula/gis-endless-eula-page.ui
@@ -5,73 +5,74 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
+ <property name="margin_start">24</property>
+ <property name="margin_end">24</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
- <property name="row_spacing">6</property>
+ <property name="row_spacing">12</property>
<child>
- <object class="GtkBox" id="box1">
+ <object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="valign">end</property>
- <property name="margin_left">12</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkCheckButton" id="metrics-checkbutton">
- <property name="label" translatable="yes">Enable metrics collection.</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="xalign">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">A few words about your Rights and our
Responsibility</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="scale" value="1.2"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator" id="separator1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="eula-scrolledwin">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkLabel" id="metrics-privacy-label">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes"><a href='metrics-privacy-policy'>Click
here</a> to see our privacy policy</property>
- <property name="use_markup">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
+ <placeholder/>
</child>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkBox" id="box2">
+ <object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">baseline</property>
- <property name="valign">start</property>
- <property name="vexpand">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
<child>
- <object class="GtkLabel" id="label1">
+ <object class="GtkCheckButton" id="metrics-checkbutton">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">start</property>
+ <property name="receives_default">False</property>
<property name="valign">start</property>
- <property name="label" translatable="yes">Terms of Service</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.2"/>
- </attributes>
+ <property name="use_stock">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -80,88 +81,29 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes">We legally have to include our terms of service. Those
are below. But here are the terms to which we would most like you to agree: May you do good and not evil. May
you find forgiveness for yourself and forgive others. May you share freely, never taking more than you give.
We promise to do our best to do the same.</property>
- <property name="wrap">True</property>
- <property name="max_width_chars">48</property>
- <attributes>
- <attribute name="scale" value="0.82999999999999996"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="margin_bottom">64</property>
- <property name="label" translatable="yes">- The Endless Team</property>
- <property name="wrap">True</property>
- <property name="max_width_chars">48</property>
- <attributes>
- <attribute name="scale" value="0.82999999999999996"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label4">
+ <object class="GtkLabel" id="metrics-privacy-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">start</property>
<property name="valign">start</property>
- <property name="label" translatable="yes">Third-party Software</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.2"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label5">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes">Endless uses third-party software to display Flash,
MP3 and other media. Some of this software is closed-source. The software is subject to the license terms
included with the software's documentation.</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes">I agree to help make Endless better for everyone by
automatically saving statistics about problems and bugs. All data is anonymous. <a
href='metrics-privacy-policy'>Learn more</a></property>
+ <property name="use_markup">True</property>
<property name="wrap">True</property>
- <property name="max_width_chars">48</property>
- <attributes>
- <attribute name="scale" value="0.82999999999999996"/>
- </attributes>
+ <property name="width_chars">48</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">4</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">0</property>
+ <property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
</object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]