Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate constants #21

Merged
merged 3 commits into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('com.github.manexim.news', 'vala', 'c')
project('com.github.manexim.news', 'vala', 'c', version: '0.1.5')

gnome = import('gnome')
i18n = import('i18n')
Expand Down
4 changes: 2 additions & 2 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Application : Granite.Application {

public Application () {
Object (
application_id: Config.APP_ID,
application_id: Constants.APP_ID,
flags: ApplicationFlags.FLAGS_NONE
);
}
Expand Down Expand Up @@ -40,7 +40,7 @@ public class Application : Granite.Application {
window.show_all ();

var css_provider = new Gtk.CssProvider ();
css_provider.load_from_resource (Config.APP_STYLES);
css_provider.load_from_resource (Constants.APP_STYLES);
Gtk.StyleContext.add_provider_for_screen (
Gdk.Screen.get_default (), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
);
Expand Down
6 changes: 3 additions & 3 deletions src/Config/Constants.vala → src/Constants.vala.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

namespace Config {
public const string APP_ID = "com.github.manexim.news";
namespace Constants {
public const string APP_ID = "@APP_ID@";
public const string APP_AUTHOR = "Manexim";
public const string APP_NAME = _("News Feed");
public const string APP_VERSION = "0.1.5";
public const string APP_VERSION = "@APP_VERSION@";
public const string APP_STYLES = "com/github/manexim/news/styles/application.css";
}
8 changes: 4 additions & 4 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class MainWindow : Hdy.Window {
var headerbar = new Hdy.HeaderBar () {
decoration_layout = "close:",
show_close_button = true,
title = Config.APP_NAME
title = Constants.APP_NAME
};

return_button = new Gtk.Button ();
Expand All @@ -46,8 +46,8 @@ public class MainWindow : Hdy.Window {

add (window_handle);

stack.add_named (new Views.FeedView (), Config.APP_NAME);
history.add (Config.APP_NAME);
stack.add_named (new Views.FeedView (), Constants.APP_NAME);
history.add (Constants.APP_NAME);

delete_event.connect (() => {
save_settings ();
Expand Down Expand Up @@ -93,7 +93,7 @@ public class MainWindow : Hdy.Window {
return_button.no_show_all = true;
return_button.visible = false;

title = Config.APP_NAME;
title = Constants.APP_NAME;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Services/ImageCache.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Services.ImageCache {
var image_path = Path.build_filename (
GLib.Environment.get_user_cache_dir (),
Path.DIR_SEPARATOR_S,
Config.APP_ID,
Constants.APP_ID,
"images"
);

Expand Down
2 changes: 1 addition & 1 deletion src/Services/Settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public class Services.Settings : Granite.Services.Settings {
public bool window_maximized { get; set; }

private Settings () {
base (Config.APP_ID);
base (Constants.APP_ID);
}
}
12 changes: 11 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
config_data = configuration_data()
config_data.set('APP_ID', meson.project_name())
config_data.set('APP_VERSION', meson.project_version())

config_file = configure_file(
input: 'Constants.vala.in',
output: '@BASENAME@',
configuration: config_data
)

sources = files(
'Actions/Actions.vala',
'Actions/ActionType.vala',
'Actions/Payload.vala',
'Config/Constants.vala',
'Middlewares/FeedMiddleware.vala',
'Middlewares/LoggingMiddleware.vala',
'Models/Article.vala',
Expand All @@ -25,6 +34,7 @@ sources = files(
executable(
meson.project_name(),
sources,
config_file,
asresources,
dependencies: dependencies,
install: true
Expand Down