From 6e42c0d5b7bbe6b6ed5e16f3e5fde3dc73be0cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 28 May 2024 07:22:10 -0700 Subject: [PATCH] Application: modernize and set up locale (#776) --- data/io.elementary.installer.gresource.xml | 2 + src/Application.vala | 56 ++++++++++------------ src/Config.vala.in | 1 + src/meson.build | 1 + 4 files changed, 28 insertions(+), 32 deletions(-) diff --git a/data/io.elementary.installer.gresource.xml b/data/io.elementary.installer.gresource.xml index 0942d91ae..e08676d4d 100644 --- a/data/io.elementary.installer.gresource.xml +++ b/data/io.elementary.installer.gresource.xml @@ -5,6 +5,8 @@ disk-bar-fallback.css ProgressView.css wallpaper.jpg + + caution.svg emblem-downloads.svg diff --git a/src/Application.vala b/src/Application.vala index 41daf293a..21062fe74 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -1,19 +1,6 @@ -// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- -/*- - * Copyright (c) 2016–2018 elementary LLC. (https://elementary.io) - * - * 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 3 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 . +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2016-2024 elementary, Inc. (https://elementary.io) * * Authored by: Corentin Noël */ @@ -26,10 +13,19 @@ public class Installer.App : Gtk.Application { public static bool test_mode; + public App () { + Object ( + application_id: "io.elementary.installer", + flags: ApplicationFlags.FLAGS_NONE + ); + } + construct { - application_id = "io.elementary.installer"; - flags = ApplicationFlags.FLAGS_NONE; - Intl.setlocale (LocaleCategory.ALL, ""); + GLib.Intl.setlocale (LocaleCategory.ALL, ""); + GLib.Intl.bindtextdomain (application_id, Build.LOCALEDIR); + GLib.Intl.bind_textdomain_codeset (application_id, "UTF-8"); + GLib.Intl.textdomain (application_id); + add_main_option_entries (INSTALLER_OPTIONS); } @@ -44,6 +40,14 @@ public class Installer.App : Gtk.Application { css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION ); + + var css_fallback = new Gtk.CssProvider (); + css_fallback.load_from_resource ("io/elementary/installer/disk-bar-fallback.css"); + Gtk.StyleContext.add_provider_for_screen ( + Gdk.Screen.get_default (), + css_fallback, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); } public override void activate () { @@ -57,17 +61,6 @@ public class Installer.App : Gtk.Application { window.show_all (); add_window (window); - weak Gtk.IconTheme default_theme = Gtk.IconTheme.get_default (); - default_theme.add_resource_path ("/io/elementary/installer"); - - var css_fallback = new Gtk.CssProvider (); - css_fallback.load_from_resource ("io/elementary/installer/disk-bar-fallback.css"); - Gtk.StyleContext.add_provider_for_screen ( - Gdk.Screen.get_default (), - css_fallback, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - inhibit ( get_active_window (), Gtk.ApplicationInhibitFlags.IDLE | Gtk.ApplicationInhibitFlags.SUSPEND, @@ -77,6 +70,5 @@ public class Installer.App : Gtk.Application { } public static int main (string[] args) { - var application = new Installer.App (); - return application.run (args); + return new Installer.App ().run (args); } diff --git a/src/Config.vala.in b/src/Config.vala.in index 550688d72..a9f6c8bd6 100644 --- a/src/Config.vala.in +++ b/src/Config.vala.in @@ -1,6 +1,7 @@ namespace Build { public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"; public const string LANG_LIST = "@LANG_LIST@"; + public const string LOCALEDIR = @LOCALEDIR@; public const string PREFERRED_LANG_LIST = "@PREFERRED_LANG_LIST@"; public const string XKB_BASE = "@XKB_BASE@"; public const string ISO_CODES_LOCATION = "@ISO_CODES_LOCATION@"; diff --git a/src/meson.build b/src/meson.build index e03557d41..432f98b23 100644 --- a/src/meson.build +++ b/src/meson.build @@ -34,6 +34,7 @@ vala_files = [ configuration_data = configuration_data() configuration_data.set('GETTEXT_PACKAGE', meson.project_name()) configuration_data.set('LANG_LIST', get_option('supported_languages')) +configuration_data.set_quoted('LOCALEDIR', get_option('prefix') / get_option('localedir')) xkbconf = dependency('xkeyboard-config') xkb_base = xkbconf.get_pkgconfig_variable('xkb_base')