diff --git a/debian/copyright b/debian/copyright index 577de3278..fca404714 100644 --- a/debian/copyright +++ b/debian/copyright @@ -64,6 +64,8 @@ Files: plinth/modules/ejabberd/static/icons/ejabberd.png plinth/modules/ejabberd/static/icons/ejabberd.svg plinth/modules/email/static/icons/email.png plinth/modules/email/static/icons/email.svg + plinth/modules/email/static/icons/gnome.png + plinth/modules/email/static/icons/gnome.svg plinth/modules/matrixsynapse/static/icons/matrixsynapse.svg plinth/modules/privoxy/static/icons/privoxy.png plinth/modules/privoxy/static/icons/privoxy.svg diff --git a/plinth/modules/gnome/__init__.py b/plinth/modules/gnome/__init__.py new file mode 100644 index 000000000..a464232f2 --- /dev/null +++ b/plinth/modules/gnome/__init__.py @@ -0,0 +1,90 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""FreedomBox app to configure GNOME desktop.""" + +from django.utils.translation import gettext_lazy as _ + +from plinth import action_utils +from plinth import app as app_module +from plinth import cfg, menu +from plinth.modules.backups.components import BackupRestore +from plinth.package import Packages +from plinth.privileged import service as service_privileged +from plinth.utils import format_lazy + +from . import manifest + +_description = [ + _('GNOME is a desktop environment that focuses on simplicity and ease of ' + 'use.'), + format_lazy( + _('This app turns your {box_name} into a desktop computer if you ' + 'physically connect a monitor, a keyboard, and a mouse to it. A ' + 'browser, an office suite, and other basic utilities are available. ' + 'You may install further graphical applications using the software ' + 'center provided within.'), box_name=_(cfg.box_name)), + _('This app is not suitable for low-end hardware. It requires at least ' + '4GiB for RAM, 4GiB or disk space and a GPU capable of basic 3D ' + 'acceleration.'), +] + + +class GNOMEApp(app_module.App): + """FreedomBox app for GNOME desktop.""" + + app_id = 'gnome' + + _version = 1 + + def __init__(self) -> None: + """Create components for the app.""" + super().__init__() + + info = app_module.Info(app_id=self.app_id, version=self._version, + name=_('GNOME'), icon_filename='gnome', + description=_description, manual_page='GNOME', + donation_url='https://www.gnome.org/donate/', + tags=manifest.tags) + self.add(info) + + menu_item = menu.Menu('menu-gnome', info.name, info.icon_filename, + info.tags, 'gnome:index', parent_url_name='apps') + self.add(menu_item) + + packages = Packages('packages-gnome', ['gnome']) + self.add(packages) + + system_target = SystemTarget('system-target-gnome', 'graphical.target') + self.add(system_target) + + backup_restore = BackupRestore('backup-restore-gnome', + **manifest.backup) + self.add(backup_restore) + + def setup(self, old_version): + """Install and configure the app.""" + super().setup(old_version) + if not old_version: + self.enable() + + +class SystemTarget(app_module.LeaderComponent): + """Component to set the default target systemd will boot into.""" + + _DEFAULT_TARGET: str = 'multi-user.target' + + def __init__(self, component_id: str, target: str): + """Initialize the component.""" + super().__init__(component_id) + self.target = target + + def is_enabled(self) -> bool: + """Return whether the component is enabled.""" + return action_utils.systemd_get_default() == self.target + + def enable(self) -> None: + """Run operations to enable the component.""" + service_privileged.systemd_set_default(self.target) + + def disable(self) -> None: + """Run operations to disable the component.""" + service_privileged.systemd_set_default(self._DEFAULT_TARGET) diff --git a/plinth/modules/gnome/data/usr/share/freedombox/modules-enabled/gnome b/plinth/modules/gnome/data/usr/share/freedombox/modules-enabled/gnome new file mode 100644 index 000000000..94ddfc9c8 --- /dev/null +++ b/plinth/modules/gnome/data/usr/share/freedombox/modules-enabled/gnome @@ -0,0 +1 @@ +plinth.modules.gnome diff --git a/plinth/modules/gnome/manifest.py b/plinth/modules/gnome/manifest.py new file mode 100644 index 000000000..de18fdb4a --- /dev/null +++ b/plinth/modules/gnome/manifest.py @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""Application manifest for GNOME.""" + +from django.utils.translation import gettext_lazy as _ + +backup = {} + +tags = [ + _('Desktop'), + _('Browser'), + _('Office suite'), + _('Software store'), + _('GUI'), + _('Graphical apps') +] diff --git a/plinth/modules/gnome/static/icons/gnome.png b/plinth/modules/gnome/static/icons/gnome.png new file mode 100644 index 000000000..4d341cb5b Binary files /dev/null and b/plinth/modules/gnome/static/icons/gnome.png differ diff --git a/plinth/modules/gnome/static/icons/gnome.svg b/plinth/modules/gnome/static/icons/gnome.svg new file mode 100644 index 000000000..4ab411c35 --- /dev/null +++ b/plinth/modules/gnome/static/icons/gnome.svg @@ -0,0 +1,549 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plinth/modules/gnome/urls.py b/plinth/modules/gnome/urls.py new file mode 100644 index 000000000..a4a4fa0f4 --- /dev/null +++ b/plinth/modules/gnome/urls.py @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""URLs for the GNOME module.""" + +from django.urls import re_path + +from plinth.views import AppView + +urlpatterns = [ + re_path(r'^apps/gnome/$', AppView.as_view(app_id='gnome'), name='index'), +]