Skip to content

Commit

Permalink
Application: modernize and set up locale (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored May 28, 2024
1 parent c5b041d commit 6e42c0d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 32 deletions.
2 changes: 2 additions & 0 deletions data/io.elementary.installer.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<file alias="disk-bar-fallback.css" compressed="true">disk-bar-fallback.css</file>
<file alias="ProgressView.css" compressed="true">ProgressView.css</file>
<file compressed="true">wallpaper.jpg</file>
</gresource>
<gresource prefix="/io/elementary/installer/icons">
<file alias="io.elementary.installer.caution.svg" compressed="true" preprocess="xml-stripblanks">caution.svg</file>
<file alias="io.elementary.installer.emblem-downloads.svg" compressed="true" preprocess="xml-stripblanks">emblem-downloads.svg</file>
</gresource>
Expand Down
56 changes: 24 additions & 32 deletions src/Application.vala
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2016-2024 elementary, Inc. (https://elementary.io)
*
* Authored by: Corentin Noël <[email protected]>
*/
Expand All @@ -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);
}

Expand All @@ -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 () {
Expand All @@ -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,
Expand All @@ -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);
}
1 change: 1 addition & 0 deletions src/Config.vala.in
Original file line number Diff line number Diff line change
@@ -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@";
Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 6e42c0d

Please sign in to comment.