diff --git a/flatpak/org.gnome.Fractal.json b/flatpak/org.gnome.Fractal.json index f093dce5..0764ef5c 100644 --- a/flatpak/org.gnome.Fractal.json +++ b/flatpak/org.gnome.Fractal.json @@ -16,7 +16,6 @@ "--filesystem=~/.config/dconf:ro", "--talk-name=ca.desrt.dconf", "--env=DCONF_USER_CONFIG_DIR=.config/dconf", - "--env=FRACTAL_ID=org.gnome.Fractal.nightly", "--share=network", "--share=ipc", "--socket=x11", @@ -33,7 +32,6 @@ ], "env" : { "CARGO_HOME" : "/run/build/Fractal/cargo", - "DEBUG" : "true", "RUST_BACKTRACE" : "1" } }, diff --git a/fractal-gtk/build.rs b/fractal-gtk/build.rs index 2ee7a5fa..a12f7d85 100644 --- a/fractal-gtk/build.rs +++ b/fractal-gtk/build.rs @@ -15,15 +15,26 @@ fn main() { // Generating build globals let default_locales = "./fractal-gtk/po".to_string(); - let out_dir = env::var("OUT_DIR").unwrap(); + let default_app_id = "org.gnome.Fractal".to_string(); + let default_name_suffix = "".to_string(); + let default_version = "".to_string(); + let localedir = env::var("FRACTAL_LOCALEDIR").unwrap_or(default_locales); + let app_id = env::var("FRACTAL_APP_ID").unwrap_or(default_app_id); + let name_suffix = env::var("FRACTAL_NAME_SUFFIX").unwrap_or(default_name_suffix); + let version = env::var("FRACTAL_VERSION").unwrap_or(default_version); + + let out_dir = env::var("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("build_globals.rs"); let mut f = File::create(&dest_path).unwrap(); let globals = format!(" pub static LOCALEDIR: &'static str = \"{}\"; +pub static APP_ID: &'static str = \"{}\"; +pub static NAME_SUFFIX: &'static str = \"{}\"; +pub static VERSION: &'static str = \"{}\"; ", - localedir); + localedir, app_id, name_suffix, version); f.write_all(&globals.into_bytes()[..]).unwrap(); } diff --git a/fractal-gtk/res/icons/meson.build b/fractal-gtk/res/icons/meson.build index eff6e4b5..27834444 100644 --- a/fractal-gtk/res/icons/meson.build +++ b/fractal-gtk/res/icons/meson.build @@ -1 +1,19 @@ -install_subdir('hicolor', install_dir: icondir) +icon_sizes = ['16x16', '22x22', '24x24', '32x32', '48x48', '512x512'] + +foreach icon_size: icon_sizes + hicolor_dir = join_paths('hicolor', icon_size, 'apps') + + install_data( + join_paths(hicolor_dir, 'org.gnome.Fractal.png'), + install_dir: join_paths(datadir, 'icons', hicolor_dir), + rename: '@0@.png'.format(application_id) + ) +endforeach + +hicolor_dir = join_paths('hicolor', 'scalable', 'apps') + +install_data( + join_paths(hicolor_dir, 'org.gnome.Fractal-symbolic.svg'), + install_dir: join_paths(datadir, 'icons', hicolor_dir), + rename: '@0@-symbolic.svg'.format(application_id) +) diff --git a/fractal-gtk/res/meson.build b/fractal-gtk/res/meson.build index d05bcec6..d6816945 100644 --- a/fractal-gtk/res/meson.build +++ b/fractal-gtk/res/meson.build @@ -1,20 +1,32 @@ subdir('icons') +desktop_conf = configuration_data() +desktop_conf.set('icon', application_id) i18n.merge_file ('desktop-file', type: 'desktop', - input: 'org.gnome.Fractal.desktop.in', - output: 'org.gnome.Fractal.desktop', + input: configure_file( + input: files('org.gnome.Fractal.desktop.in.in'), + output: 'org.gnome.Fractal.desktop.in', + configuration: desktop_conf + ), + output: '@0@.desktop'.format(application_id), po_dir: podir, install: true, install_dir: join_paths (datadir, 'applications') ) +appdata_conf = configuration_data() +appdata_conf.set('appid', application_id) i18n.merge_file ('appdata-file', - input: 'org.gnome.Fractal.appdata.xml.in', - output: 'org.gnome.Fractal.appdata.xml', + input: configure_file( + input: files('org.gnome.Fractal.appdata.xml.in.in'), + output: 'org.gnome.Fractal.appdata.xml.in', + configuration: appdata_conf + ), + output: '@0@.appdata.xml'.format(application_id), po_dir: podir, install: true, - install_dir: join_paths (datadir, 'appdata') + install_dir: join_paths (datadir, 'metainfo') ) install_data('org.gnome.Fractal.gschema.xml', install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas')) diff --git a/fractal-gtk/res/org.gnome.Fractal.appdata.xml.in b/fractal-gtk/res/org.gnome.Fractal.appdata.xml.in.in similarity index 98% rename from fractal-gtk/res/org.gnome.Fractal.appdata.xml.in rename to fractal-gtk/res/org.gnome.Fractal.appdata.xml.in.in index fe713bc2..1cea72ab 100644 --- a/fractal-gtk/res/org.gnome.Fractal.appdata.xml.in +++ b/fractal-gtk/res/org.gnome.Fractal.appdata.xml.in.in @@ -1,6 +1,6 @@ - org.gnome.Fractal.desktop + @appid@.desktop Fractal GPL-3.0 CC0-1.0 diff --git a/fractal-gtk/res/org.gnome.Fractal.desktop.in b/fractal-gtk/res/org.gnome.Fractal.desktop.in.in similarity index 96% rename from fractal-gtk/res/org.gnome.Fractal.desktop.in rename to fractal-gtk/res/org.gnome.Fractal.desktop.in.in index 65edbdaa..94bdc759 100644 --- a/fractal-gtk/res/org.gnome.Fractal.desktop.in +++ b/fractal-gtk/res/org.gnome.Fractal.desktop.in.in @@ -4,7 +4,7 @@ Comment=Fractal is a decentralized, secure messaging client for collaborative gr GenericName=Fractal group messaging Exec=fractal # Translators: Do NOT translate or transliterate this text (this is an icon file name)! -Icon=org.gnome.Fractal +Icon=@icon@ Type=Application StartupNotify=true X-GNOME-UsesNotifications=true diff --git a/fractal-gtk/src/app/mod.rs b/fractal-gtk/src/app/mod.rs index 3c09680e..b296101d 100644 --- a/fractal-gtk/src/app/mod.rs +++ b/fractal-gtk/src/app/mod.rs @@ -62,16 +62,16 @@ pub struct App { impl App { /// Create an App instance pub fn new() { - let appid = match env::var("FRACTAL_ID") { - Ok(id) => id, - Err(_) => globals::APP_ID.to_string(), - }; + let appid = globals::APP_ID.to_string(); let gtk_app = gtk::Application::new(Some(&appid[..]), gio::ApplicationFlags::empty()) .expect("Failed to initialize GtkApplication"); gtk_app.set_accels_for_action("app.quit", &["Q"]); + let path = "/org/gnome/Fractal".to_string(); + gtk_app.set_property_resource_base_path(Some(&path)); + gtk_app.connect_startup(move |gtk_app| { let (tx, rx): (Sender, Receiver) = channel(); let (itx, irx): (Sender, Receiver) = channel(); diff --git a/fractal-gtk/src/appop/about.rs b/fractal-gtk/src/appop/about.rs index 086b2a21..e815222c 100644 --- a/fractal-gtk/src/appop/about.rs +++ b/fractal-gtk/src/appop/about.rs @@ -14,14 +14,16 @@ impl AppOp { .get_object("main_window") .expect("Can't find main_window in ui file."); + let program_name = format!("Fractal{}", globals::NAME_SUFFIX); + let dialog = gtk::AboutDialog::new(); dialog.set_logo_icon_name(globals::APP_ID); dialog.set_comments(i18n("A Matrix.org client for GNOME").as_str()); dialog.set_copyright(i18n("© 2017–2018 Daniel García Moreno, et al.").as_str()); dialog.set_license_type(gtk::License::Gpl30); dialog.set_modal(true); - dialog.set_version(env!("CARGO_PKG_VERSION")); - dialog.set_program_name("Fractal"); + dialog.set_version(globals::VERSION); + dialog.set_program_name(&program_name); dialog.set_website("https://wiki.gnome.org/Fractal"); dialog.set_website_label(i18n("Learn more about Fractal").as_str()); dialog.set_translator_credits(i18n("translator-credits").as_str()); diff --git a/fractal-gtk/src/globals.rs b/fractal-gtk/src/globals.rs index e87a40e1..802b01d6 100644 --- a/fractal-gtk/src/globals.rs +++ b/fractal-gtk/src/globals.rs @@ -3,7 +3,6 @@ pub static CACHE_SIZE: usize = 40; pub static MSG_ICON_SIZE: i32 = 40; pub static USERLIST_ICON_SIZE: i32 = 30; pub static MINUTES_TO_SPLIT_MSGS: i64 = 30; -pub static APP_ID: &'static str = "org.gnome.Fractal"; pub static DEFAULT_HOMESERVER: &'static str = "https://matrix.org"; pub static DEFAULT_IDENTITYSERVER: &'static str = "https://vector.im"; diff --git a/meson.build b/meson.build index 4644dffe..8876a6ec 100644 --- a/meson.build +++ b/meson.build @@ -4,6 +4,23 @@ project( license: 'GPLv3', ) +if get_option('profile') == 'development' + profile = 'Devel' + name_suffix = ' (Development)' + vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip() + if vcs_tag == '' + version_suffix = '-devel' + else + version_suffix = '-@0@'.format (vcs_tag) + endif +else + profile = '' + name_suffix = '' + version_suffix = '' +endif + +application_id = 'org.gnome.Fractal@0@'.format(profile) + fractal_version = meson.project_version() version_array = fractal_version.split('.') fractal_major_version = version_array[0].to_int() @@ -15,7 +32,6 @@ fractal_bindir = join_paths(fractal_prefix, get_option('bindir')) fractal_localedir = join_paths(fractal_prefix, get_option('localedir')) datadir = get_option('datadir') -icondir = join_paths(datadir, 'icons') i18n = import('i18n') @@ -40,7 +56,15 @@ cargo_release = custom_target('cargo-build', output: ['fractal'], install: true, install_dir: fractal_bindir, - command: [cargo_script, '@CURRENT_SOURCE_DIR@', '@OUTPUT@', fractal_localedir]) + command: [cargo_script, + '@CURRENT_SOURCE_DIR@', + '@OUTPUT@', + fractal_localedir, + application_id, + name_suffix, + fractal_version + version_suffix, + profile + ]) run_target('release', command: ['scripts/release.sh', meson.project_name() + '-' + fractal_version diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..4c5cc399 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,9 @@ +option ( + 'profile', + type: 'combo', + choices: [ + 'default', + 'development' + ], + value: 'default' +) diff --git a/scripts/cargo.sh b/scripts/cargo.sh index f6e0c568..ad89e247 100755 --- a/scripts/cargo.sh +++ b/scripts/cargo.sh @@ -2,8 +2,12 @@ export CARGO_HOME=$1/target/cargo-home export FRACTAL_LOCALEDIR="$3" +export FRACTAL_APP_ID="$4" +export FRACTAL_NAME_SUFFIX="$5" +export FRACTAL_VERSION="$6" +export FRACTAL_PROFILE="$7" -if [[ $DEBUG = true ]] +if [[ "$FRACTAL_PROFILE" == "Devel" ]] then echo "DEBUG MODE" cargo build --manifest-path $1/Cargo.toml -p fractal-gtk && cp $1/target/debug/fractal-gtk $2