[gnome-initial-setup] Add a page to configure software sources



commit 40962bb6cc4d978fac351a2423fabe7fc76dab6b
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Aug 26 19:40:07 2016 -0400

    Add a page to configure software sources
    
    This currently just adds a page with a switch; the actual
    mechanism to change repository configuration is still missing.

 configure.ac                                       |    1 +
 gnome-initial-setup/Makefile.am                    |    1 +
 gnome-initial-setup/gnome-initial-setup.c          |    2 +
 gnome-initial-setup/pages/Makefile.am              |    3 +-
 gnome-initial-setup/pages/software/Makefile.am     |   26 +++
 .../pages/software/gis-software-page.c             |  126 +++++++++++++
 .../pages/software/gis-software-page.h             |   58 ++++++
 .../pages/software/gis-software-page.ui            |  184 ++++++++++++++++++++
 .../pages/software/software.gresource.xml          |    6 +
 9 files changed, 406 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 61c756c..8fbdcd9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -136,6 +136,7 @@ gnome-initial-setup/pages/privacy/Makefile
 gnome-initial-setup/pages/goa/Makefile
 gnome-initial-setup/pages/account/Makefile
 gnome-initial-setup/pages/password/Makefile
+gnome-initial-setup/pages/software/Makefile
 gnome-initial-setup/pages/summary/Makefile
 po/Makefile.in
 ])
diff --git a/gnome-initial-setup/Makefile.am b/gnome-initial-setup/Makefile.am
index e3430fb..d275dda 100644
--- a/gnome-initial-setup/Makefile.am
+++ b/gnome-initial-setup/Makefile.am
@@ -41,6 +41,7 @@ gnome_initial_setup_LDADD =   \
        pages/goa/libgisgoa.la \
        pages/account/libgisaccount.la \
        pages/password/libgispassword.la \
+       pages/software/libgissoftware.la \
        pages/summary/libgissummary.la \
        $(INITIAL_SETUP_LIBS) \
        -lm
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index 57284ba..b99206f 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -43,6 +43,7 @@
 #include "pages/network/gis-network-page.h"
 #include "pages/timezone/gis-timezone-page.h"
 #include "pages/privacy/gis-privacy-page.h"
+#include "pages/software/gis-software-page.h"
 #include "pages/goa/gis-goa-page.h"
 #include "pages/account/gis-account-pages.h"
 #include "pages/password/gis-password-page.h"
@@ -68,6 +69,7 @@ static PageData page_table[] = {
   PAGE (network,  FALSE),
   PAGE (privacy,  FALSE),
   PAGE (timezone, TRUE),
+  PAGE (software, FALSE),
   PAGE (goa,      FALSE),
   PAGE (account,  TRUE),
   PAGE (password, TRUE),
diff --git a/gnome-initial-setup/pages/Makefile.am b/gnome-initial-setup/pages/Makefile.am
index 95618bc..e5182a7 100644
--- a/gnome-initial-setup/pages/Makefile.am
+++ b/gnome-initial-setup/pages/Makefile.am
@@ -10,4 +10,5 @@ SUBDIRS = \
        goa \
        account \
        password \
-       summary
+       summary \
+       software
diff --git a/gnome-initial-setup/pages/software/Makefile.am b/gnome-initial-setup/pages/software/Makefile.am
new file mode 100644
index 0000000..ce820ad
--- /dev/null
+++ b/gnome-initial-setup/pages/software/Makefile.am
@@ -0,0 +1,26 @@
+
+noinst_LTLIBRARIES = libgissoftware.la
+
+pkgdatadir = $(datadir)/gnome-initial-setup
+
+AM_CPPFLAGS = \
+       -DPKGDATADIR="\"$(pkgdatadir)\""
+
+BUILT_SOURCES =
+
+resource_files = $(shell glib-compile-resources --sourcedir=$(srcdir) --generate-dependencies 
$(srcdir)/software.gresource.xml)
+software-resources.c: software.gresource.xml $(resource_files)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $<
+software-resources.h: software.gresource.xml $(resource_files)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-header $<
+BUILT_SOURCES += software-resources.c software-resources.h
+
+libgissoftware_la_SOURCES =                    \
+       gis-software-page.c gis-software-page.h \
+       $(BUILT_SOURCES)
+
+libgissoftware_la_CFLAGS = $(INITIAL_SETUP_CFLAGS) -I "$(srcdir)/../.."
+libgissoftware_la_LIBADD = $(INITIAL_SETUP_LIBS)
+libgissoftware_la_LDFLAGS = -export_dynamic -avoid-version -module -no-undefined
+
+EXTRA_DIST = software.gresource.xml $(resource_files)
diff --git a/gnome-initial-setup/pages/software/gis-software-page.c 
b/gnome-initial-setup/pages/software/gis-software-page.c
new file mode 100644
index 0000000..aea7405
--- /dev/null
+++ b/gnome-initial-setup/pages/software/gis-software-page.c
@@ -0,0 +1,126 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright (C) 2012 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Written by:
+ *     Jasper St. Pierre <jstpierre mecheye net>
+ */
+
+/* SOFTWARE pages {{{1 */
+
+#define PAGE_ID "software"
+
+#include "config.h"
+#include "software-resources.h"
+#include "gis-software-page.h"
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+
+struct _GisSoftwarePagePrivate
+{
+  GtkWidget *more_popover;
+  GtkWidget *proprietary_switch;
+};
+
+typedef struct _GisSoftwarePagePrivate GisSoftwarePagePrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GisSoftwarePage, gis_software_page, GIS_TYPE_PAGE);
+
+static void
+gis_software_page_constructed (GObject *object)
+{
+  GisSoftwarePage *page = GIS_SOFTWARE_PAGE (object);
+  GisSoftwarePagePrivate *priv = gis_software_page_get_instance_private (page);
+
+  G_OBJECT_CLASS (gis_software_page_parent_class)->constructed (object);
+
+  gtk_widget_show (GTK_WIDGET (page));
+}
+
+static void
+gis_software_page_dispose (GObject *object)
+{
+  GisSoftwarePage *page = GIS_SOFTWARE_PAGE (object);
+  GisSoftwarePagePrivate *priv = gis_software_page_get_instance_private (page);
+
+  G_OBJECT_CLASS (gis_software_page_parent_class)->dispose (object);
+}
+
+static void
+gis_software_page_locale_changed (GisPage *page)
+{
+  gis_page_set_title (GIS_PAGE (page), _("Software Sources"));
+}
+
+static gboolean
+activate_link (const char *label,
+               const char *uri,
+               gpointer    data)
+{
+  GisSoftwarePage *page = GIS_SOFTWARE_PAGE (data);
+  GisSoftwarePagePrivate *priv = gis_software_page_get_instance_private (page);
+
+  gtk_widget_show (priv->more_popover);
+}
+
+static gboolean
+state_set (GtkSwitch *sw,
+           gboolean   state,
+           gpointer   data)
+{
+  g_print ("%s proprietary software sources\n", state ? "Enable" : "Disable");
+
+  gtk_switch_set_state (sw, state);
+
+  return TRUE;
+}
+
+static void
+gis_software_page_class_init (GisSoftwarePageClass *klass)
+{
+  GisPageClass *page_class = GIS_PAGE_CLASS (klass);
+  GObjectClass *object_class = G_OBJECT_CLASS (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_callback (GTK_WIDGET_CLASS (klass), activate_link);
+  gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), state_set);
+
+  page_class->page_id = PAGE_ID;
+  page_class->locale_changed = gis_software_page_locale_changed;
+  object_class->constructed = gis_software_page_constructed;
+  object_class->dispose = gis_software_page_dispose;
+}
+
+static void
+gis_software_page_init (GisSoftwarePage *page)
+{
+  g_resources_register (software_get_resource ());
+
+  gtk_widget_init_template (GTK_WIDGET (page));
+}
+
+void
+gis_prepare_software_page (GisDriver *driver)
+{
+  gis_driver_add_page (driver,
+                       g_object_new (GIS_TYPE_SOFTWARE_PAGE,
+                                     "driver", driver,
+                                     NULL));
+}
diff --git a/gnome-initial-setup/pages/software/gis-software-page.h 
b/gnome-initial-setup/pages/software/gis-software-page.h
new file mode 100644
index 0000000..6bceda1
--- /dev/null
+++ b/gnome-initial-setup/pages/software/gis-software-page.h
@@ -0,0 +1,58 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright (C) 2012 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Written by:
+ *     Matthias Clasen <mclasen redhat com>
+ */
+
+#ifndef __GIS_SOFTWARE_PAGE_H__
+#define __GIS_SOFTWARE_PAGE_H__
+
+#include <glib-object.h>
+
+#include "gnome-initial-setup.h"
+
+G_BEGIN_DECLS
+
+#define GIS_TYPE_SOFTWARE_PAGE               (gis_software_page_get_type ())
+#define GIS_SOFTWARE_PAGE(obj)                           (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GIS_TYPE_SOFTWARE_PAGE, GisSoftwarePage))
+#define GIS_SOFTWARE_PAGE_CLASS(klass)                   (G_TYPE_CHECK_CLASS_CAST ((klass),  
GIS_TYPE_SOFTWARE_PAGE, GisSoftwarePageClass))
+#define GIS_IS_SOFTWARE_PAGE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIS_TYPE_SOFTWARE_PAGE))
+#define GIS_IS_SOFTWARE_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GIS_TYPE_SOFTWARE_PAGE))
+#define GIS_SOFTWARE_PAGE_GET_CLASS(obj)                 (G_TYPE_INSTANCE_GET_CLASS ((obj),  
GIS_TYPE_SOFTWARE_PAGE, GisSoftwarePageClass))
+
+typedef struct _GisSoftwarePage        GisSoftwarePage;
+typedef struct _GisSoftwarePageClass   GisSoftwarePageClass;
+
+struct _GisSoftwarePage
+{
+  GisPage parent;
+};
+
+struct _GisSoftwarePageClass
+{
+  GisPageClass parent_class;
+};
+
+GType gis_software_page_get_type (void);
+
+void gis_prepare_software_page (GisDriver *driver);
+
+G_END_DECLS
+
+#endif /* __GIS_SOFTWARE_PAGE_H__ */
+
diff --git a/gnome-initial-setup/pages/software/gis-software-page.ui 
b/gnome-initial-setup/pages/software/gis-software-page.ui
new file mode 100644
index 0000000..0a43baa
--- /dev/null
+++ b/gnome-initial-setup/pages/software/gis-software-page.ui
@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="halign">center</property>
+        <property name="valign">fill</property>
+        <child>
+          <object class="GtkImage" id="image">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_top">24</property>
+            <property name="pixel_size">96</property>
+            <property name="icon_name">folder-download-symbolic</property>
+            <style>
+              <class name="dim-label" />
+            </style>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel" id="title">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">center</property>
+            <property name="valign">start</property>
+            <property name="margin_bottom">18</property>
+            <property name="label" translatable="yes">Software Sources</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+              <attribute name="scale" value="1.8"/>
+            </attributes>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="visible">True</property>
+            <property name="margin-top">40</property>
+            <property name="xalign">0.5</property>
+            <property name="max-width-chars">50</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>
+          <object class="GtkLabel" id="more_label">
+            <property name="visible">True</property>
+            <property name="margin-top">15</property>
+            <property name="halign">center</property>
+            <property name="max-width-chars">50</property>
+            <property name="use-markup">True</property>
+            <property name="label" translatable="yes">&lt;a href="more"&gt;Find out 
moreā€¦&lt;/a&gt;</property>
+            <signal name="activate-link" handler="activate_link"/>
+          </object>
+        </child>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="margin-top">40</property>
+            <property name="orientation">horizontal</property>
+            <property name="homogeneous">True</property>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Proprietary Software Sources</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
+              </object>
+            </child>
+            <child>
+              <object class="GtkSwitch" id="proprietary_switch">
+                <property name="halign">end</property>
+                <property name="visible">True</property>
+                <signal name="state-set" handler="state_set"/>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="orientation">horizontal</property>
+            <property name="valign">end</property>
+            <property name="halign">center</property>
+            <property name="spacing">64</property>
+            <property name="margin_bottom">64</property>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="pixel_size">64</property>
+                <property name="opacity">0.5</property>
+                <property name="icon_name">web-browser-symbolic</property>
+                <style>
+                  <class name="dim-label" />
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="pixel_size">64</property>
+                <property name="opacity">0.5</property>
+                <property name="icon_name">text-editor-symbolic</property>
+                <style>
+                  <class name="dim-label" />
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="pixel_size">64</property>
+                <property name="opacity">0.5</property>
+                <property name="icon_name">help-faq-symbolic</property>
+                <style>
+                  <class name="dim-label" />
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="pixel_size">64</property>
+                <property name="opacity">0.5</property>
+                <property name="icon_name">input-gaming-symbolic</property>
+                <style>
+                  <class name="dim-label" />
+                </style>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+  <object class="GtkPopover" id="more_popover">
+    <property name="relative-to">more_label</property>
+    <property name="position">bottom</property>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">1</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkLabel">
+            <property name="visible">1</property>
+            <property name="max-width-chars">40</property>
+            <property name="margin-top">20</property>
+            <property name="margin-start">20</property>
+            <property name="margin-end">20</property>
+            <property name="margin-bottom">10</property>
+            <property name="wrap">True</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">Proprietary software is software that is owned by an 
individual or company. There are often restrictions on its use and its source code cannot usually be 
accessed.</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="visible">1</property>
+            <property name="max-width-chars">40</property>
+            <property name="wrap">True</property>
+            <property name="xalign">0</property>
+            <property name="margin-start">20</property>
+            <property name="margin-end">20</property>
+            <property name="margin-bottom">30</property>
+            <property name="label" translatable="yes">This contrasts with Free Software, which can be freely 
run, copied, distributed, studied and modified.</property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/gnome-initial-setup/pages/software/software.gresource.xml 
b/gnome-initial-setup/pages/software/software.gresource.xml
new file mode 100644
index 0000000..1f8384c
--- /dev/null
+++ b/gnome-initial-setup/pages/software/software.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/initial-setup">
+    <file preprocess="xml-stripblanks" alias="gis-software-page.ui">gis-software-page.ui</file>
+  </gresource>
+</gresources>


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