Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 15 additions & 26 deletions .github/workflows/macos-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,40 +60,29 @@ jobs:
meson compile -C builddir
meson install -C builddir

- name: 🧱 Create .app bundle
- name: ⚙️ Package it with pyinstaller
run: |
mkdir -p MyApp.app/Contents/MacOS
cp install/bin/my-gtk-app MyApp.app/Contents/MacOS/
cp -r install/share MyApp.app/Contents/Resources/
# Create basic Info.plist
cat > MyApp.app/Contents/Info.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key><string>MyApp</string>
<key>CFBundleIdentifier</key><string>com.example.myapp</string>
<key>CFBundleVersion</key><string>${{ github.ref_name }}</string>
<key>CFBundleExecutable</key><string>my-gtk-app</string>
<key>CFBundlePackageType</key><string>APPL</string>
</dict>
</plist>
EOF
pyinstaller --name Scriptorium \
--windowed \
--add-data "builddir:." \
install/bin/scriptorium
codesign --deep --force --sign - dist/Scriptorium.app

- name: 📀 Create DMG
run: |
mkdir -p dist
rm -f dist/Scriptorium.dmg
create-dmg \
--volname "MyApp" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--icon "MyApp.app" 200 190 \
--volname "Scriptorium" \
--window-size 1000 800 \
--icon "Scriptorium.app" 200 190 \
--app-drop-link 600 185 \
dist/ \
MyApp.app
"dist/Scriptorium.dmg" \
"dist/"


- name: 📤 Upload DMG artifact
uses: actions/upload-artifact@v4
with:
name: MyApp-macos-dmg
name: Scriptorium-macos-dmg
path: dist/*.dmg
2 changes: 1 addition & 1 deletion scriptorium/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
import gi
gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
gi.require_version("WebKit", "6.0")
gi.require_version("Tsparql", "3.0")
gi.require_version("WebKit", "6.0")

8 changes: 2 additions & 6 deletions scriptorium/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
import sys
from scriptorium.widgets.multiline_entry_row import MultiLineEntryRow
from gi.repository import Gio, Adw, WebKit, GLib
from gi.repository import Gio, Adw, GLib
from .window import ScrptWindow
import logging

Expand Down Expand Up @@ -54,11 +54,7 @@ def __init__(self):
current_value = self.settings.get_string("style-variant")
style_variant_action.activate(GLib.Variant('s', current_value))

# Force loading WebKit, otherwise it is not recognized in Builder
dummy = WebKit.WebView()
del dummy

# Same for MultiLineEntryRow
# Force loading MultiLineEntryRow, otherwise it is not recognized in Builder
dummy = MultiLineEntryRow()
del dummy

Expand Down
12 changes: 1 addition & 11 deletions scriptorium/views/editor_formatting.blp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Gtk 4.0;
using Adw 1;
using WebKit 6.0;

template $ScrptFormattingPanel: Adw.NavigationPage {
title: "Formatting";
Expand Down Expand Up @@ -76,19 +75,10 @@ template $ScrptFormattingPanel: Adw.NavigationPage {
margin-start: 12;
margin-end: 12;

Box {
Box web_view_placeholder {
styles [
"card",
]
WebKit.WebView web_view {
zoom-level: 1;
vexpand: true;
hexpand: true;
margin-start: 6;
margin-end: 6;
margin-top: 6;
margin-bottom: 6;
}
}
}
};
Expand Down
39 changes: 35 additions & 4 deletions scriptorium/views/editor_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

from gi.repository import Adw, Gtk, Gio, GObject
import logging
from gi.repository import Adw, Gtk, Gio
from scriptorium.models import Chapter
from scriptorium.globals import BASE
import logging

try:
from gi.repository import WebKit
HAVE_WEBKIT = True
except ImportError:
HAVE_WEBKIT = False

logger = logging.getLogger(__name__)

Expand All @@ -33,7 +39,7 @@ class ScrptFormattingPanel(Adw.NavigationPage):
__icon_name__ = "open-book-symbolic"
__description__ = "Preview and modify the formatting"

web_view = Gtk.Template.Child()
web_view_placeholder = Gtk.Template.Child()
button_next = Gtk.Template.Child()
button_previous = Gtk.Template.Child()
chapters_drop_down = Gtk.Template.Child()
Expand All @@ -42,6 +48,29 @@ def __init__(self, editor, **kwargs):
super().__init__(**kwargs)
self._editor = editor

# If we have WebKit set the component, otherwise show placeholder
if HAVE_WEBKIT:
logger.info("Webkit is available")
self.web_view = WebKit.WebView()
self.web_view.set_zoom_level(1)
self.web_view.set_margin_start(6)
self.web_view.set_margin_end(6)
self.web_view.set_margin_top(6)
self.web_view.set_margin_bottom(6)
self.web_view.set_vexpand(True)
self.web_view.set_hexpand(True)
self.web_view_placeholder.append(self.web_view)
else:
widget = Adw.StatusPage(
title = "Not available",
icon_name = "process-stop-symbolic",
description = "This feature is not available on your operating system"
)
widget.set_vexpand(True)
widget.set_hexpand(True)
self.web_view_placeholder.append(widget)


self.chapters_drop_down.connect(
"notify::selected-item",
self.on_selected_item
Expand All @@ -57,6 +86,7 @@ def __init__(self, editor, **kwargs):

self._position = 0


def on_selected_item(self, _drop_down, _selected_item):
selected_chapter = _drop_down.get_selected_item()
if selected_chapter is None:
Expand All @@ -77,7 +107,8 @@ def on_selected_item(self, _drop_down, _selected_item):
html_content = html_content.replace("{content}", content)

# Load the content
self.web_view.load_html(html_content)
if HAVE_WEBKIT:
self.web_view.load_html(html_content)

# Find the position of the chapter
chapters = self._editor.project.manuscript.chapters
Expand Down
Loading