Skip to content

Commit

Permalink
Native WebView implementation (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusTomlinson authored Jun 15, 2024
1 parent 949b3d7 commit b2e3dfa
Show file tree
Hide file tree
Showing 20 changed files with 151 additions and 125 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build & Test

on: [push]

jobs:
build_and_test:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build
id: snapcraft
uses: snapcore/action-build@v1

- uses: actions/upload-artifact@v3
with:
name: snap
path: ${{ steps.snapcraft.outputs.snap }}
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
node_modules
dist
*.snap
*.user
build
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "subprojects/choc"]
path = subprojects/choc
url = https://github.com/cross-platform/choc.git
branch = fork
4 changes: 4 additions & 0 deletions .vscode/_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"C_Cpp.default.cppStandard": "c++17",
"lldb.showDisassembly": "never"
}
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run",
"preLaunchTask": "Build",
"program": "${workspaceFolder}/build/icloud-for-linux",
"args": ["notes", "Notes"],
"cwd": "${workspaceFolder}",
"request": "launch",
"type": "cppdbg",
"osx": {
"type": "lldb"
}
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"C_Cpp.default.cppStandard": "c++17",
"lldb.showDisassembly": "never"
}
27 changes: 27 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"command": [
"cp .vscode/_settings.json .vscode/settings.json &&",
"mkdir -p build &&",
"cd build &&",
"cmake -DCMAKE_BUILD_TYPE=Debug .. &&",
"cmake --build . -j8 --config Debug"
],
"problemMatcher": {
"base": "$gcc",
"fileLocation": [
"relative",
"${workspaceFolder}/build/"
]
}
}
]
}
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.16)

project(icloud-for-linux)

set(CMAKE_CXX_STANDARD 17)

include_directories(subprojects/choc)

add_executable(
${PROJECT_NAME}
src/main.cpp
)

if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
find_package(PkgConfig REQUIRED)
pkg_check_modules (gtk3 REQUIRED gtk+-3.0 IMPORTED_TARGET)
pkg_check_modules (webkit2 REQUIRED webkit2gtk-4.0 IMPORTED_TARGET)
target_link_libraries (${PROJECT_NAME} PUBLIC pthread PkgConfig::gtk3 PkgConfig::webkit2)
else()
target_link_libraries(${PROJECT_NAME} "-framework WebKit")
endif()

install(TARGETS ${PROJECT_NAME} DESTINATION bin)
Binary file not shown.
52 changes: 0 additions & 52 deletions main.js

This file was deleted.

15 changes: 0 additions & 15 deletions package.json

This file was deleted.

2 changes: 1 addition & 1 deletion snap/gui/drive.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Type=Application
Categories=Office
Icon=${SNAP}/meta/gui/drive.png
Exec=icloud-for-linux.drive
StartupWMClass=icloud-for-linux.iclouddrive
StartupWMClass=icloud-for-linux.drive
10 changes: 0 additions & 10 deletions snap/gui/find-my-friends.desktop

This file was deleted.

Binary file removed snap/gui/find-my-friends.png
Binary file not shown.
10 changes: 0 additions & 10 deletions snap/gui/find-my-iphone.desktop

This file was deleted.

10 changes: 10 additions & 0 deletions snap/gui/find.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Version=0.11
Name=iCloud Find
GenericName=iCloud Find
Comment=iCloud Find
Type=Application
Categories=Office
Icon=${SNAP}/meta/gui/find.png
Exec=icloud-for-linux.find
StartupWMClass=icloud-for-linux.find
File renamed without changes
50 changes: 16 additions & 34 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: icloud-for-linux
version: '0.13'
version: '0.14'
summary: iCloud for Linux
description: iCloud for Linux

Expand All @@ -9,27 +9,14 @@ base: core20

parts:
icloud-for-linux:
plugin: nil
plugin: cmake
source: .
override-build: |
npm install electron electron-packager
npx electron-packager . --overwrite --platform=linux --output=release-build --prune=true
cp -rv ./icloud-for-linux-linux-* $SNAPCRAFT_PART_INSTALL/icloud-for-linux
chmod +xr $SNAPCRAFT_PART_INSTALL/icloud-for-linux
build-snaps:
- node/16/stable
build-packages:
- unzip
stage-packages:
- libnss3
- libnspr4
dump:
source: dump
plugin: dump
cmake-parameters:
- -DCMAKE_INSTALL_PREFIX=/usr

apps:
mail:
command: icloud-for-linux/icloud-for-linux --no-sandbox mail
command: usr/bin/icloud-for-linux mail
extensions: &extensions
- gnome-3-38
plugs: &plugs
Expand All @@ -44,57 +31,52 @@ apps:
environment: &environment
TMPDIR: $XDG_RUNTIME_DIR
contacts:
command: icloud-for-linux/icloud-for-linux --no-sandbox contacts
command: usr/bin/icloud-for-linux contacts Contacts
extensions: *extensions
plugs: *plugs
environment: *environment
calendar:
command: icloud-for-linux/icloud-for-linux --no-sandbox calendar
command: usr/bin/icloud-for-linux calendar Calendar
extensions: *extensions
plugs: *plugs
environment: *environment
photos:
command: icloud-for-linux/icloud-for-linux --no-sandbox photos
command: usr/bin/icloud-for-linux photos Photos
extensions: *extensions
plugs: *plugs
environment: *environment
drive:
command: icloud-for-linux/icloud-for-linux --no-sandbox iclouddrive
command: usr/bin/icloud-for-linux iclouddrive Drive
extensions: *extensions
plugs: *plugs
environment: *environment
notes:
command: icloud-for-linux/icloud-for-linux --no-sandbox notes
command: usr/bin/icloud-for-linux notes Notes
extensions: *extensions
plugs: *plugs
environment: *environment
reminders:
command: icloud-for-linux/icloud-for-linux --no-sandbox reminders
command: usr/bin/icloud-for-linux reminders Reminders
extensions: *extensions
plugs: *plugs
environment: *environment
pages:
command: icloud-for-linux/icloud-for-linux --no-sandbox pages
command: usr/bin/icloud-for-linux pages Pages
extensions: *extensions
plugs: *plugs
environment: *environment
numbers:
command: icloud-for-linux/icloud-for-linux --no-sandbox numbers
command: usr/bin/icloud-for-linux numbers Numbers
extensions: *extensions
plugs: *plugs
environment: *environment
keynote:
command: icloud-for-linux/icloud-for-linux --no-sandbox keynote
command: usr/bin/icloud-for-linux keynote Keynote
extensions: *extensions
plugs: *plugs
environment: *environment
find-my-friends:
command: icloud-for-linux/icloud-for-linux --no-sandbox fmf
extensions: *extensions
plugs: *plugs
environment: *environment
find-my-iphone:
command: icloud-for-linux/icloud-for-linux --no-sandbox find
find:
command: usr/bin/icloud-for-linux find Find
extensions: *extensions
plugs: *plugs
environment: *environment
21 changes: 21 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <gui/choc_WebView.h>
#include <gui/choc_DesktopWindow.h>
#include <gui/choc_MessageLoop.h>

int main(int, char **argv)
{
choc::ui::DesktopWindow appWin(choc::ui::Bounds{0, 0, 0, 0});
appWin.centreWithSize(1000, 600);
appWin.setWindowTitle( "iCloud " + std::string(argv[2]) );
appWin.windowClosed = []()
{ choc::messageloop::stop(); };

choc::ui::WebView webView;
webView.navigate("https://www.icloud.com/" + std::string(argv[1]));

appWin.setContent(webView.getViewHandle());
appWin.toFront();

choc::messageloop::run();
return 0;
}
1 change: 1 addition & 0 deletions subprojects/choc
Submodule choc added at e33026

0 comments on commit b2e3dfa

Please sign in to comment.