mirror of
https://github.com/mileswolfallen2/gelectron.git
synced 2026-12-04 16:07:43 +00:00
feat: implement application icon support for macOS
- Removed package.json and code signature files from the macOS app bundle. - Added support for setting application icons via base64 encoded PNG strings. - Enhanced the main application logic to detect and apply icons from various locations. - Updated the Electron app and browser window classes to handle icon setting. - Introduced new methods for decoding PNG icons and applying them to the application and window. - Updated Cargo.toml to include the cocoa dependency for macOS.
This commit is contained in:
1 parent
a7b6f9a072
commit
da521a33a0
37 files changed
+513
-5076
No files matched your search
@@ -17,12 +17,22 @@ class NativeImage {
|
||||
try {
|
||||
const fs = require('fs');
|
||||
const data = fs.readFileSync(path);
|
||||
// Basic PNG header parsing for dimensions
|
||||
img._data = data;
|
||||
img._isEmpty = false;
|
||||
if (data.length > 24 && data[0] === 0x89 && data[1] === 0x50) {
|
||||
img._width = data.readUInt32BE(16);
|
||||
img._height = data.readUInt32BE(20);
|
||||
img._data = data;
|
||||
img._isEmpty = false;
|
||||
} else if (data.length > 22 && data[0] === 0x00 && data[1] === 0x00 && data[2] === 0x01 && data[3] === 0x00) {
|
||||
img._width = data[6] || 256;
|
||||
img._height = data[7] || 256;
|
||||
} else if (data.length > 12 && data[0] === 0x69 && data[1] === 0x63 && data[2] === 0x6e && data[3] === 0x73) {
|
||||
const type = data.toString('ascii', 8, 12);
|
||||
const c = type.charCodeAt(1);
|
||||
if (c >= 0x30 && c <= 0x39) {
|
||||
img._width = img._height = 1 << (c - 0x30);
|
||||
} else if (type[0] === 'p' && c >= 0x34 && c <= 0x38) {
|
||||
img._width = img._height = 16 << (c - 0x34);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`[gelectron] Failed to load image: ${path}`, err.message);
|
||||
@@ -109,9 +119,6 @@ class NativeImage {
|
||||
isTemplateImage() {
|
||||
return this._isTemplate || false;
|
||||
}
|
||||
|
||||
toPNG(options) { return this.toPNG(options); }
|
||||
toJPEG(quality) { return this.toJPEG(quality); }
|
||||
}
|
||||
|
||||
module.exports = NativeImage;
|
||||
Reference in new issue
Block a user