Skip to content

Commit 06f6a0b

Browse files
add icon
1 parent 548e0df commit 06f6a0b

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

desktop/assets/graphite.icns

220 KB
Binary file not shown.

desktop/bundle/src/common.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ use std::process::{Command, Stdio};
55

66
pub(crate) const APP_NAME: &str = "Graphite";
77

8+
pub(crate) fn workspace_path() -> PathBuf {
9+
PathBuf::from(env!("CARGO_WORKSPACE_DIR"))
10+
}
11+
812
fn profile_name() -> &'static str {
913
let mut profile = env!("CARGO_PROFILE");
1014
if profile == "debug" {
@@ -14,7 +18,7 @@ fn profile_name() -> &'static str {
1418
}
1519

1620
pub(crate) fn profile_path() -> PathBuf {
17-
PathBuf::from(env!("CARGO_WORKSPACE_DIR")).join(format!("target/{}", env!("CARGO_PROFILE")))
21+
workspace_path().join(format!("target/{}", env!("CARGO_PROFILE")))
1822
}
1923

2024
pub(crate) fn cef_path() -> PathBuf {

desktop/bundle/src/mac.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ const APP_ID: &str = "rs.graphite.GraphiteEditor";
1010
const PACKAGE: &str = "graphite-desktop-platform-mac";
1111
const HELPER_BIN: &str = "graphite-desktop-platform-mac-helper";
1212

13+
const ICONS_FILE_NAME: &str = "graphite.icns";
14+
1315
const EXEC_PATH: &str = "Contents/MacOS";
1416
const FRAMEWORKS_PATH: &str = "Contents/Frameworks";
15-
const FRAMEWORK: &str = "Chromium Embedded Framework.framework";
17+
const RESOURCES_PATH: &str = "Contents/Resources";
18+
const CEF_FRAMEWORK: &str = "Chromium Embedded Framework.framework";
1619

1720
pub fn main() -> Result<(), Box<dyn Error>> {
1821
let app_bin = build_bin(PACKAGE, None)?;
@@ -46,7 +49,13 @@ fn bundle(out_dir: &Path, app_bin: &Path, helper_bin: &Path) -> PathBuf {
4649
create_app(&helper_app_dir, &helper_id, &helper_name, helper_bin, true);
4750
}
4851

49-
copy_dir(&cef_path().join(FRAMEWORK), &app_dir.join(FRAMEWORKS_PATH).join(FRAMEWORK));
52+
copy_dir(&cef_path().join(CEF_FRAMEWORK), &app_dir.join(FRAMEWORKS_PATH).join(CEF_FRAMEWORK));
53+
54+
let resource_dir = app_dir.join(RESOURCES_PATH);
55+
fs::create_dir_all(&resource_dir).expect("failed to create app resource dir");
56+
57+
let icon_file = workspace_path().join("desktop/assets").join(ICONS_FILE_NAME);
58+
fs::copy(icon_file, resource_dir.join(ICONS_FILE_NAME)).expect("failed to copy icon file");
5059

5160
app_dir
5261
}
@@ -61,25 +70,22 @@ fn create_app(app_dir: &Path, id: &str, name: &str, bin: &Path, is_helper: bool)
6170

6271
fn create_info_plist(dir: &Path, id: &str, exec_name: &str, is_helper: bool) -> Result<(), Box<dyn std::error::Error>> {
6372
let info = InfoPlist {
64-
cf_bundle_development_region: "en".to_string(),
73+
cf_bundle_name: exec_name.to_string(),
74+
cf_bundle_identifier: id.to_string(),
6575
cf_bundle_display_name: exec_name.to_string(),
6676
cf_bundle_executable: exec_name.to_string(),
67-
cf_bundle_identifier: id.to_string(),
77+
cf_bundle_icon_file: ICONS_FILE_NAME.to_string(),
6878
cf_bundle_info_dictionary_version: "6.0".to_string(),
69-
cf_bundle_name: exec_name.to_string(),
7079
cf_bundle_package_type: "APPL".to_string(),
7180
cf_bundle_signature: "????".to_string(),
7281
cf_bundle_version: "0.0.0".to_string(),
7382
cf_bundle_short_version_string: "0.0".to_string(),
83+
cf_bundle_development_region: "en".to_string(),
7484
ls_environment: [("MallocNanoZone".to_string(), "0".to_string())].iter().cloned().collect(),
7585
ls_file_quarantine_enabled: true,
7686
ls_minimum_system_version: "11.0".to_string(),
7787
ls_ui_element: if is_helper { Some("1".to_string()) } else { None },
78-
ns_bluetooth_always_usage_description: exec_name.to_string(),
7988
ns_supports_automatic_graphics_switching: true,
80-
ns_web_browser_publickey_credential_usage_description: exec_name.to_string(),
81-
ns_camera_usage_description: exec_name.to_string(),
82-
ns_microphone_usage_description: exec_name.to_string(),
8389
};
8490

8591
let plist_file = dir.join("Info.plist");
@@ -89,18 +95,18 @@ fn create_info_plist(dir: &Path, id: &str, exec_name: &str, is_helper: bool) ->
8995

9096
#[derive(serde::Serialize)]
9197
struct InfoPlist {
92-
#[serde(rename = "CFBundleDevelopmentRegion")]
93-
cf_bundle_development_region: String,
98+
#[serde(rename = "CFBundleName")]
99+
cf_bundle_name: String,
100+
#[serde(rename = "CFBundleIdentifier")]
101+
cf_bundle_identifier: String,
94102
#[serde(rename = "CFBundleDisplayName")]
95103
cf_bundle_display_name: String,
96104
#[serde(rename = "CFBundleExecutable")]
97105
cf_bundle_executable: String,
98-
#[serde(rename = "CFBundleIdentifier")]
99-
cf_bundle_identifier: String,
106+
#[serde(rename = "CFBundleIconFile")]
107+
cf_bundle_icon_file: String,
100108
#[serde(rename = "CFBundleInfoDictionaryVersion")]
101109
cf_bundle_info_dictionary_version: String,
102-
#[serde(rename = "CFBundleName")]
103-
cf_bundle_name: String,
104110
#[serde(rename = "CFBundlePackageType")]
105111
cf_bundle_package_type: String,
106112
#[serde(rename = "CFBundleSignature")]
@@ -109,6 +115,8 @@ struct InfoPlist {
109115
cf_bundle_version: String,
110116
#[serde(rename = "CFBundleShortVersionString")]
111117
cf_bundle_short_version_string: String,
118+
#[serde(rename = "CFBundleDevelopmentRegion")]
119+
cf_bundle_development_region: String,
112120
#[serde(rename = "LSEnvironment")]
113121
ls_environment: HashMap<String, String>,
114122
#[serde(rename = "LSFileQuarantineEnabled")]
@@ -117,14 +125,6 @@ struct InfoPlist {
117125
ls_minimum_system_version: String,
118126
#[serde(rename = "LSUIElement")]
119127
ls_ui_element: Option<String>,
120-
#[serde(rename = "NSBluetoothAlwaysUsageDescription")]
121-
ns_bluetooth_always_usage_description: String,
122128
#[serde(rename = "NSSupportsAutomaticGraphicsSwitching")]
123129
ns_supports_automatic_graphics_switching: bool,
124-
#[serde(rename = "NSWebBrowserPublicKeyCredentialUsageDescription")]
125-
ns_web_browser_publickey_credential_usage_description: String,
126-
#[serde(rename = "NSCameraUsageDescription")]
127-
ns_camera_usage_description: String,
128-
#[serde(rename = "NSMicrophoneUsageDescription")]
129-
ns_microphone_usage_description: String,
130130
}

0 commit comments

Comments
 (0)