summaryrefslogtreecommitdiffstats
path: root/gnome-initial-setup/pages/software
diff options
context:
space:
mode:
Diffstat (limited to 'gnome-initial-setup/pages/software')
-rw-r--r--gnome-initial-setup/pages/software/gis-software-page.c179
-rw-r--r--gnome-initial-setup/pages/software/gis-software-page.h58
-rw-r--r--gnome-initial-setup/pages/software/gis-software-page.ui41
-rw-r--r--gnome-initial-setup/pages/software/gis-software-symbolic.svg1
-rw-r--r--gnome-initial-setup/pages/software/meson.build10
-rw-r--r--gnome-initial-setup/pages/software/software.gresource.xml9
6 files changed, 298 insertions, 0 deletions
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..b68d143
--- /dev/null
+++ b/gnome-initial-setup/pages/software/gis-software-page.c
@@ -0,0 +1,179 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright (C) 2016, 2021 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>
+ * Kalev Lember <klember@redhat.com>
+ * Michael Catanzaro <mcatanzaro@redhat.com>
+ */
+
+/* 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>
+
+#include "gis-page-header.h"
+
+struct _GisSoftwarePagePrivate
+{
+ GtkWidget *header;
+ GtkWidget *enable_disable_button;
+ gboolean enabled;
+};
+
+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);
+
+ G_OBJECT_CLASS (gis_software_page_parent_class)->constructed (object);
+
+ gis_page_set_complete (GIS_PAGE (page), TRUE);
+}
+
+/* Distro-specific stuff is isolated here so that the rest of this page can be
+ * used by other distros. Feel free to add your distro here.
+ */
+static char *
+find_fedora_third_party (void)
+{
+ return g_find_program_in_path ("fedora-third-party");
+}
+
+static gboolean
+should_show_software_page (void)
+{
+ g_autofree char *has_fedora_third_party = find_fedora_third_party ();
+ return has_fedora_third_party != NULL;
+}
+
+static gboolean
+gis_software_page_apply (GisPage *gis_page,
+ GCancellable *cancellable)
+{
+ GisSoftwarePage *page = GIS_SOFTWARE_PAGE (gis_page);
+ GisSoftwarePagePrivate *priv = gis_software_page_get_instance_private (page);
+ g_autofree char *program = NULL;
+ g_autoptr (GError) error = NULL;
+
+ program = find_fedora_third_party ();
+
+ if (program)
+ {
+ const char *arg1;
+
+ if (priv->enabled)
+ arg1 = "enable";
+ else
+ arg1 = "disable";
+
+ gis_pkexec (program, arg1, "root", &error);
+ if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("%s failed: %s", program, error->message);
+ }
+
+ return FALSE;
+}
+
+static void
+gis_software_page_locale_changed (GisPage *gis_page)
+{
+ GisSoftwarePage *page = GIS_SOFTWARE_PAGE (gis_page);
+ GisSoftwarePagePrivate *priv = gis_software_page_get_instance_private (page);
+
+ gis_page_set_title (GIS_PAGE (page), _("Third-Party Repositories"));
+ g_object_set (priv->header, "subtitle", _("Third-party repositories provide access to additional software from selected external sources, including popular apps and drivers that are important for some devices. Some proprietary software is included."), NULL);
+}
+
+static void
+enabled_state_changed (GisSoftwarePage *page)
+{
+ GisSoftwarePagePrivate *priv = gis_software_page_get_instance_private (page);
+
+ if (priv->enabled)
+ {
+ gtk_button_set_label (GTK_BUTTON (priv->enable_disable_button), _("_Disable Third-Party Repositories"));
+ gtk_widget_remove_css_class (priv->enable_disable_button, "suggested-action");
+ }
+ else
+ {
+ gtk_button_set_label (GTK_BUTTON (priv->enable_disable_button), _("_Enable Third-Party Repositories"));
+ gtk_widget_add_css_class (priv->enable_disable_button, "suggested-action");
+ }
+}
+
+static gboolean
+enable_disable_button_clicked_cb (GtkButton *button,
+ GisSoftwarePage *page)
+{
+ GisSoftwarePagePrivate *priv = gis_software_page_get_instance_private (page);
+ priv->enabled = !priv->enabled;
+ enabled_state_changed (page);
+ return GDK_EVENT_STOP;
+}
+
+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, header);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisSoftwarePage, enable_disable_button);
+ gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), enable_disable_button_clicked_cb);
+
+ page_class->page_id = PAGE_ID;
+ page_class->locale_changed = gis_software_page_locale_changed;
+ page_class->apply = gis_software_page_apply;
+ object_class->constructed = gis_software_page_constructed;
+}
+
+static void
+gis_software_page_init (GisSoftwarePage *page)
+{
+ g_resources_register (software_get_resource ());
+ g_type_ensure (GIS_TYPE_PAGE_HEADER);
+
+ gtk_widget_init_template (GTK_WIDGET (page));
+ enabled_state_changed (page);
+}
+
+GisPage *
+gis_prepare_software_page (GisDriver *driver)
+{
+ GisPage *page = NULL;
+ if (should_show_software_page ())
+ {
+ page = g_object_new (GIS_TYPE_SOFTWARE_PAGE,
+ "driver", driver,
+ NULL);
+ }
+
+ return page;
+}
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..8d15245
--- /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);
+
+GisPage *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..838c24d
--- /dev/null
+++ b/gnome-initial-setup/pages/software/gis-software-page.ui
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GisSoftwarePage" parent="GisPage">
+ <child>
+ <object class="AdwPreferencesPage">
+ <child>
+ <object class="AdwPreferencesGroup">
+ <child>
+ <object class="GisPageHeader" id="header">
+ <property name="margin_top">24</property>
+ <property name="title" translatable="yes">Third-Party Repositories</property>
+ <property name="icon_name">gis-software-symbolic</property>
+ <property name="show_icon" bind-source="GisSoftwarePage" bind-property="small-screen" bind-flags="invert-boolean|sync-create"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwPreferencesGroup">
+ <child>
+ <object class="GtkButton" id="enable_disable_button">
+ <property name="halign">center</property>
+ <property name="margin-top">36</property>
+ <property name="margin-bottom">36</property>
+ <property name="margin-start">36</property>
+ <property name="margin-end">36</property>
+ <property name="use-underline">True</property>
+ <property name="visible">True</property>
+ <signal name="clicked" handler="enable_disable_button_clicked_cb"/>
+ <style>
+ <class name="suggested-action" />
+ <class name="pill" />
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/gnome-initial-setup/pages/software/gis-software-symbolic.svg b/gnome-initial-setup/pages/software/gis-software-symbolic.svg
new file mode 100644
index 0000000..f344c64
--- /dev/null
+++ b/gnome-initial-setup/pages/software/gis-software-symbolic.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g fill="#474747"><path d="M.002 12c.004-.224.112-.53.304-.704l2.161-2.117c.233-.243.787-.292 1.011-.157.081.002 1.136.632 1.289.866.616.946-.344 1.827-1.174 1.547l-.35-.212-1.602 1.572C1.004 13.32-.051 12.887 0 12zM11.62.118c.389-.101.79-.11 1.17-.08l-1.36 2.305a.975.975 0 00.354 1.348l.874.508a.99.99 0 001.357-.353l1.36-2.306c.212.314.4.666.502 1.053.486 1.853-.632 3.748-2.497 4.234-.39.101-.79.11-1.17.08l-.803 1.116L7.997 8s1.52-2.577 1.628-2.595a3.483 3.483 0 01-.502-1.053C8.636 2.5 9.754.604 11.619.118z" style="line-height:normal;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration-line:none;text-transform:none;marker:none" color="#000" font-weight="400" font-family="Sans" overflow="visible"/><path d="M3.599.719a3.5 3.5 0 00-.655.219c-.017.624.086 1.441-.157 1.656-.238.21-1.036.034-1.653-.031a3.63 3.63 0 00-.312.75c.477.395 1.138.839 1.154 1.156.016.32-.625.805-1.06 1.25.102.258.249.493.405.719.607-.127 1.364-.374 1.623-.188.262.19.264 1.005.343 1.625.249.075.512.105.78.125.28-.555.566-1.32.874-1.406.315-.089.962.458 1.497.781.219-.152.413-.337.593-.531-.253-.573-.72-1.292-.593-1.594.128-.302.974-.47 1.56-.687.005-.074.032-.145.032-.22 0-.19-.035-.378-.063-.562-.605-.16-1.465-.241-1.622-.531-.157-.288.241-1.061.437-1.656a3.682 3.682 0 00-.656-.469c-.5.375-1.082.994-1.404.938-.316-.056-.662-.82-.998-1.344-.04.007-.085-.008-.125 0zm.624 1.875a1.686 1.686 0 11-1.685 1.688c0-.933.754-1.688 1.685-1.688z" style="marker:none" color="#000" overflow="visible"/><path d="M2.997 9h9.985l.008 6.063c0 .492-.472.937-.994.937H4.004a.996.996 0 01-.999-1z" style="marker:none" color="#bebebe" overflow="visible"/><path d="M15.96 11.977c-.003-.224-.112-.53-.303-.704l-2.162-2.117c-.232-.243-.786-.292-1.01-.156-.081.002-1.136.63-1.289.865-.616.946.344 1.827 1.174 1.547l.35-.212 1.602 1.572c.637.526 1.691.092 1.639-.795z" style="line-height:normal;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration-line:none;text-transform:none;marker:none" color="#000" font-weight="400" font-family="Sans" overflow="visible"/></g></svg> \ No newline at end of file
diff --git a/gnome-initial-setup/pages/software/meson.build b/gnome-initial-setup/pages/software/meson.build
new file mode 100644
index 0000000..c464ec7
--- /dev/null
+++ b/gnome-initial-setup/pages/software/meson.build
@@ -0,0 +1,10 @@
+sources += gnome.compile_resources(
+ 'software-resources',
+ files('software.gresource.xml'),
+ c_name: 'software'
+)
+
+sources += files(
+ 'gis-software-page.c',
+ 'gis-software-page.h'
+)
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..caee9bd
--- /dev/null
+++ b/gnome-initial-setup/pages/software/software.gresource.xml
@@ -0,0 +1,9 @@
+<?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>
+ <gresource prefix="/org/gnome/InitialSetup/icons">
+ <file compressed="true" alias="scalable/actions/gis-software-symbolic.svg" preprocess="xml-stripblanks">gis-software-symbolic.svg</file>
+ </gresource>
+</gresources>