2 Commits

Author SHA1 Message Date
deepend-tildeclub
b8a7ccf005 Merge pull request #277 from ZoiteChat/fix-window-restore
Defer topic relayout after restore-down
2026-06-05 09:15:10 -06:00
68fc53585e Defer topic relayout after restore-down 2026-06-04 15:24:37 -06:00
15 changed files with 158 additions and 285 deletions

View File

@@ -62,11 +62,6 @@ jobs:
rm -rf AppDir
DESTDIR="${PWD}/AppDir" ninja -C build install
- name: Verify offline docs install
run: |
set -eux
test -f AppDir/usr/share/doc/zoitechat/html/index.html
- name: Bundle scripting runtimes in AppDir
run: |
set -eux

View File

@@ -37,12 +37,6 @@ jobs:
cache: false
restore-cache: false
- name: Verify offline docs install
run: |
flatpak --user install -y zoitechat.flatpak
app_dir="$(flatpak info --user --show-location net.zoite.Zoitechat)"
test -f "$app_dir/files/share/zoitechat/offline-docs/index.html"
- name: Upload Flatpak Bundle
id: upload_flatpak
uses: actions/upload-artifact@v6

View File

@@ -132,16 +132,6 @@ jobs:
msbuild win32\zoitechat.sln /m /verbosity:minimal /p:Configuration=Release /p:Platform=${{ matrix.platform }}
shell: cmd
- name: Verify offline docs install
run: |
if not exist "..\zoitechat-build\${{ matrix.platform }}\rel\offline-docs\index.html" exit /b 1
findstr /C:"Name:" "..\zoitechat-build\${{ matrix.platform }}\bin\zoitechat.iss" | findstr /C:"docs"
findstr /C:"OFFLINEDOCSURL" "..\zoitechat-build\${{ matrix.platform }}\bin\zoitechat.iss"
findstr /C:"Source:" "..\zoitechat-build\${{ matrix.platform }}\bin\zoitechat.iss" | findstr /C:"offline-docs"
findstr /C:"offline-docs.tar.gz" "..\zoitechat-build\${{ matrix.platform }}\bin\zoitechat.iss"
findstr /C:"InstallOfflineDocs" "..\zoitechat-build\${{ matrix.platform }}\bin\zoitechat.iss"
shell: cmd
- name: Preparing Artifacts
run: |
move ..\zoitechat-build\${{ matrix.platform }}\ZoiteChat-*.exe .\

View File

@@ -7,15 +7,3 @@ if get_option('gtk-frontend')
subdir('misc')
subdir('man')
endif
offline_docs_url = get_option('offline-docs-url')
offline_docs = custom_target('offline-docs',
output: 'offline-docs.stamp',
command: [find_program('python3'), files('misc/fetch_offline_docs.py'), offline_docs_url, '@OUTDIR@', meson.source_root()],
build_by_default: true,
)
meson.add_install_script(
files('misc/install_offline_docs.py'),
join_paths(meson.current_build_dir(), 'offline-docs'),
offline_docs_dir,
)

View File

@@ -1,89 +0,0 @@
#!/usr/bin/env python3
import html
import io
import pathlib
import shutil
import sys
import tarfile
import tempfile
import urllib.error
import urllib.request
url = sys.argv[1]
out_dir = pathlib.Path(sys.argv[2])
source_dir = pathlib.Path(sys.argv[3]) if len(sys.argv) > 3 else pathlib.Path.cwd()
docs_dir = out_dir / "offline-docs"
if docs_dir.exists():
shutil.rmtree(docs_dir)
docs_dir.mkdir(parents=True, exist_ok=True)
def write_source_docs() -> None:
parts = [
'<!doctype html><html><head><meta charset="utf-8">'
"<title>ZoiteChat Documentation</title></head><body>"
"<h1>ZoiteChat Documentation</h1>"
]
for name in ("readme.md", "troubleshooting.md", "changelog.rst"):
path = source_dir / name
if path.exists():
parts.append(
f"<h2>{html.escape(name)}</h2>"
f"<pre>{html.escape(path.read_text(encoding='utf-8', errors='replace'))}</pre>"
)
parts.append("</body></html>")
(docs_dir / "index.html").write_text("\n".join(parts), encoding="utf-8")
def safe_extract(tar: tarfile.TarFile, target: pathlib.Path) -> None:
target = target.resolve()
for member in tar.getmembers():
member_path = (target / member.name).resolve()
if not str(member_path).startswith(str(target) + "/"):
raise tarfile.TarError(f"unsafe archive path: {member.name}")
tar.extractall(target)
def copy_index_tree(extracted_dir: pathlib.Path) -> bool:
indexes = sorted(extracted_dir.rglob("index.html"))
if not indexes:
return False
root = indexes[0].parent
for item in root.iterdir():
dest = docs_dir / item.name
if item.is_dir():
shutil.copytree(item, dest, dirs_exist_ok=True)
else:
shutil.copy2(item, dest)
return (docs_dir / "index.html").exists()
if url:
try:
with urllib.request.urlopen(url, timeout=30) as response:
data = response.read()
with tempfile.TemporaryDirectory() as tmp:
extract_dir = pathlib.Path(tmp)
with tarfile.open(fileobj=io.BytesIO(data), mode="r:gz") as tar:
safe_extract(tar, extract_dir)
if not copy_index_tree(extract_dir):
write_source_docs()
except (OSError, tarfile.TarError, urllib.error.URLError) as error:
print(f"offline docs download failed: {error}", file=sys.stderr)
write_source_docs()
else:
write_source_docs()
(out_dir / "offline-docs.stamp").write_text("ok", encoding="utf-8")

View File

@@ -1,13 +0,0 @@
#!/usr/bin/env python3
import os
import pathlib
import shutil
import sys
src = pathlib.Path(sys.argv[1])
dest = pathlib.Path(os.environ['MESON_INSTALL_DESTDIR_PREFIX']) / sys.argv[2]
if not (src / 'index.html').exists():
sys.exit(0)
if dest.exists():
shutil.rmtree(dest)
shutil.copytree(src, dest)

View File

@@ -56,9 +56,7 @@
"-Ddbus-service-use-appid=true",
"-Dwith-perl=perl",
"-Dwith-python=python3",
"-Dwith-lua=lua",
"-Doffline-docs-package=net.zoite.Zoitechat",
"-Doffline-docs-dir=share/zoitechat/offline-docs"
"-Dwith-lua=lua"
],
"build-options": {
"cflags": "-Wno-error=missing-include-dirs"

View File

@@ -32,18 +32,8 @@ config_h = configuration_data()
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
config_h.set_quoted('PACKAGE_NAME', meson.project_name())
config_h.set_quoted('GETTEXT_PACKAGE', 'zoitechat')
offline_docs_package = get_option('offline-docs-package')
if offline_docs_package == ''
offline_docs_package = meson.project_name()
endif
offline_docs_dir = get_option('offline-docs-dir')
if offline_docs_dir == ''
offline_docs_dir = join_paths(get_option('datadir'), 'doc', offline_docs_package, 'html')
endif
config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'),
get_option('datadir'), 'locale'))
config_h.set_quoted('ZOITECHATDOCDIR', join_paths(get_option('prefix'),
offline_docs_dir))
config_h.set10('ENABLE_NLS', true)
# Optional features

View File

@@ -62,13 +62,3 @@ option('with-upd', type: 'boolean',
option('with-perl-legacy-api', type: 'boolean', value: false,
description: 'Enables the legacy IRC perl module for compatibility with old scripts'
)
option('offline-docs-url', type: 'string', value: 'https://dl.zoitechat.org/offlinedocs/zoitechat-docs-html-2.18.1.tar.gz',
description: 'URL for offline documentation archive (tar.gz)'
)
option('offline-docs-package', type: 'string', value: '',
description: 'Package or app id to use under the installed documentation directory'
)
option('offline-docs-dir', type: 'string', value: '',
description: 'Installed offline documentation directory relative to prefix'
)

View File

@@ -66,5 +66,4 @@ build() {
package() {
meson install -C build --destdir "$pkgdir"
test -f "$pkgdir/usr/share/doc/zoitechat/html/index.html"
}

View File

@@ -44,7 +44,6 @@ REM zoitechat.rc needs to be in UCS-2 or Resource Compiler will complain
powershell "Get-Content -Encoding UTF8 '$(ZoiteChatLib)zoitechat.rc.utf8' | Out-File '$(ZoiteChatLib)zoitechat.rc'; Remove-Item '$(ZoiteChatLib)zoitechat.rc.utf8'"
"$(DepsRoot)\bin\glib-compile-resources.exe" --generate-header --manual-register --sourcedir "$(DataDir)" --target "$(ZoiteChatLib)resources.h" "$(DataDir)zoitechat.gresource.xml"
"$(DepsRoot)\bin\glib-compile-resources.exe" --generate-source --manual-register --sourcedir "$(DataDir)" --target "$(ZoiteChatLib)resources.c" "$(DataDir)zoitechat.gresource.xml"
"$(Python3Path)\python.exe" "$(DataDir)misc\fetch_offline_docs.py" "$(OfflineDocsUrl)" "$(ZoiteChatRel)." "$(SolutionDir).."
]]></Command>
<Message>Build zoitechat.rc and gresource file</Message>
</PreBuildEvent>

View File

@@ -872,6 +872,10 @@ fe_set_title (session *sess)
static void
mg_topicbar_update_height (GtkWidget *topic);
static void
mg_topicbar_queue_relayout (GtkWidget *topic);
static void
mg_queue_window_relayout (GtkWidget *window);
static session *
mg_session_from_window (GtkWidget *wid)
@@ -891,6 +895,57 @@ mg_session_from_window (GtkWidget *wid)
return current_sess;
}
static gboolean
mg_window_relayout_idle_cb (gpointer userdata)
{
GtkWidget *window = GTK_WIDGET (userdata);
session *sess;
g_object_set_data (G_OBJECT (window), "mg-window-relayout-source", NULL);
sess = mg_session_from_window (window);
if (sess && sess->gui)
{
if (GTK_IS_WIDGET (sess->gui->topic_entry))
mg_topicbar_queue_relayout (sess->gui->topic_entry);
if (GTK_IS_XTEXT (sess->gui->xtext))
{
gtk_xtext_refresh (GTK_XTEXT (sess->gui->xtext));
gtk_widget_queue_resize (sess->gui->xtext);
gtk_widget_queue_draw (sess->gui->xtext);
}
if (GTK_IS_WIDGET (sess->gui->window))
{
gtk_widget_queue_resize (sess->gui->window);
gtk_widget_queue_draw (sess->gui->window);
}
}
g_object_unref (window);
return G_SOURCE_REMOVE;
}
static void
mg_queue_window_relayout (GtkWidget *window)
{
guint source_id;
if (!window || !GTK_IS_WIDGET (window))
return;
if (g_object_get_data (G_OBJECT (window), "mg-window-relayout-source") != NULL)
return;
source_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
mg_window_relayout_idle_cb,
g_object_ref (window),
NULL);
g_object_set_data (G_OBJECT (window), "mg-window-relayout-source",
GUINT_TO_POINTER (source_id));
}
static gboolean
mg_windowstate_cb (GtkWindow *wid, GdkEventWindowState *event, gpointer userdata)
{
@@ -939,18 +994,10 @@ mg_windowstate_cb (GtkWindow *wid, GdkEventWindowState *event, gpointer userdata
}
sess = mg_session_from_window (GTK_WIDGET (wid));
if (sess && sess->gui && GTK_IS_WIDGET (sess->gui->topic_entry))
{
mg_topicbar_update_height (sess->gui->topic_entry);
gtk_widget_queue_draw (sess->gui->topic_entry);
}
if (sess && sess->gui && GTK_IS_XTEXT (sess->gui->xtext))
{
gtk_xtext_refresh (GTK_XTEXT (sess->gui->xtext));
gtk_widget_queue_draw (sess->gui->xtext);
}
if (sess && sess->gui && GTK_IS_WIDGET (sess->gui->window))
gtk_widget_queue_draw (sess->gui->window);
mg_queue_window_relayout (sess->gui->window);
else
mg_queue_window_relayout (GTK_WIDGET (wid));
if (current_sess && current_sess->gui)
menu_set_fullscreen (current_sess->gui, prefs.hex_gui_win_fullscreen);
@@ -1050,21 +1097,10 @@ mg_configure_cb (GtkWidget *wid, GdkEventConfigure *event, session *sess)
}
target_sess = mg_session_from_window (wid);
if (target_sess && target_sess->gui)
{
if (GTK_IS_WIDGET (target_sess->gui->topic_entry))
{
mg_topicbar_update_height (target_sess->gui->topic_entry);
gtk_widget_queue_draw (target_sess->gui->topic_entry);
}
if (GTK_IS_XTEXT (target_sess->gui->xtext))
{
gtk_xtext_refresh (GTK_XTEXT (target_sess->gui->xtext));
gtk_widget_queue_draw (target_sess->gui->xtext);
}
if (GTK_IS_WIDGET (target_sess->gui->window))
gtk_widget_queue_draw (target_sess->gui->window);
}
if (target_sess && target_sess->gui && GTK_IS_WIDGET (target_sess->gui->window))
mg_queue_window_relayout (target_sess->gui->window);
else
mg_queue_window_relayout (wid);
return FALSE;
}
@@ -3111,33 +3147,51 @@ mg_create_dialogbuttons (GtkWidget *box)
static void
mg_topicbar_update_height (GtkWidget *topic)
{
GtkWidget *scroller;
GtkWidget *parent;
GtkWidget *grandparent;
GtkTextBuffer *buffer;
GtkTextIter start;
GtkTextIter end;
GtkTextView *view;
PangoLayout *layout;
char *text;
int width;
int line_height;
int line_count;
int target_height;
int margin_left;
int margin_right;
int margin_top;
int margin_bottom;
int old_height;
PangoContext *context;
PangoFontMetrics *metrics;
if (!topic || !GTK_IS_TEXT_VIEW (topic))
return;
scroller = gtk_widget_get_parent (topic);
view = GTK_TEXT_VIEW (topic);
parent = gtk_widget_get_parent (topic);
grandparent = parent ? gtk_widget_get_parent (parent) : NULL;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (topic));
margin_left = gtk_text_view_get_left_margin (view);
margin_right = gtk_text_view_get_right_margin (view);
margin_top = gtk_text_view_get_top_margin (view);
margin_bottom = gtk_text_view_get_bottom_margin (view);
buffer = gtk_text_view_get_buffer (view);
gtk_text_buffer_get_bounds (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
layout = gtk_widget_create_pango_layout (topic, text && text[0] ? text : " ");
g_free (text);
width = gtk_widget_get_allocated_width (topic) - 8;
if (width > 0)
pango_layout_set_width (layout, width * PANGO_SCALE);
width = gtk_widget_get_allocated_width (topic);
if (width <= 1 && parent)
width = gtk_widget_get_allocated_width (parent);
width -= margin_left + margin_right;
if (width < 1)
width = 1;
pango_layout_set_width (layout, width * PANGO_SCALE);
pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
context = gtk_widget_get_pango_context (topic);
@@ -3149,44 +3203,95 @@ mg_topicbar_update_height (GtkWidget *topic)
pango_font_metrics_unref (metrics);
if (line_height <= 0)
line_height = 16;
line_count = pango_layout_get_line_count (layout);
if (line_count <= 0)
line_count = 1;
target_height = line_height * line_count;
if (target_height < line_height)
target_height = line_height;
gtk_widget_set_size_request (topic, -1, target_height);
if (scroller && GTK_IS_SCROLLED_WINDOW (scroller))
target_height = (line_height * line_count) + margin_top + margin_bottom;
if (target_height < line_height + margin_top + margin_bottom)
target_height = line_height + margin_top + margin_bottom;
old_height = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (topic),
"mg-topicbar-target-height"));
if (old_height != target_height)
{
gtk_scrolled_window_set_max_content_height (GTK_SCROLLED_WINDOW (scroller), -1);
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (scroller), -1);
gtk_scrolled_window_set_max_content_height (GTK_SCROLLED_WINDOW (scroller), target_height);
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (scroller), target_height);
gtk_widget_set_size_request (scroller, -1, target_height);
gtk_widget_queue_resize (scroller);
}
else
{
gtk_widget_queue_resize (topic);
g_object_set_data (G_OBJECT (topic), "mg-topicbar-target-height",
GINT_TO_POINTER (target_height));
gtk_widget_set_size_request (topic, -1, target_height);
if (parent && GTK_IS_SCROLLED_WINDOW (parent))
{
gtk_scrolled_window_set_max_content_height (GTK_SCROLLED_WINDOW (parent), -1);
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (parent), -1);
gtk_scrolled_window_set_max_content_height (GTK_SCROLLED_WINDOW (parent), target_height);
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (parent), target_height);
gtk_widget_set_size_request (parent, -1, target_height);
}
}
gtk_widget_queue_resize (topic);
if (parent)
gtk_widget_queue_resize (parent);
if (grandparent)
gtk_widget_queue_resize (grandparent);
gtk_widget_queue_draw (topic);
g_object_unref (layout);
}
static gboolean
mg_topicbar_relayout_idle_cb (gpointer userdata)
{
GtkWidget *topic = GTK_WIDGET (userdata);
g_object_set_data (G_OBJECT (topic), "mg-topicbar-relayout-source", NULL);
mg_topicbar_update_height (topic);
g_object_unref (topic);
return G_SOURCE_REMOVE;
}
static void
mg_topicbar_queue_relayout (GtkWidget *topic)
{
guint source_id;
if (!topic || !GTK_IS_TEXT_VIEW (topic))
return;
if (g_object_get_data (G_OBJECT (topic), "mg-topicbar-relayout-source") != NULL)
return;
source_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
mg_topicbar_relayout_idle_cb,
g_object_ref (topic),
NULL);
g_object_set_data (G_OBJECT (topic), "mg-topicbar-relayout-source",
GUINT_TO_POINTER (source_id));
}
static void
mg_topicbar_buffer_changed_cb (GtkTextBuffer *buffer, gpointer userdata)
{
(void) buffer;
mg_topicbar_update_height (GTK_WIDGET (userdata));
mg_topicbar_queue_relayout (GTK_WIDGET (userdata));
}
static void
mg_topicbar_size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer userdata)
{
(void) allocation;
int old_width;
(void) userdata;
mg_topicbar_update_height (widget);
old_width = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
"mg-topicbar-allocated-width"));
if (allocation->width == old_width)
return;
g_object_set_data (G_OBJECT (widget), "mg-topicbar-allocated-width",
GINT_TO_POINTER (allocation->width));
mg_topicbar_queue_relayout (widget);
}
void

View File

@@ -1717,32 +1717,7 @@ menu_ctcpguiopen (void)
static void
menu_docs (GtkWidget *wid, gpointer none)
{
GNetworkMonitor *monitor;
char *offline_docs;
gboolean online;
offline_docs = g_build_filename (get_xdir (), "offline-docs", "index.html", NULL);
if (g_access (offline_docs, R_OK) == 0)
{
fe_open_url (offline_docs);
g_free (offline_docs);
return;
}
g_free (offline_docs);
offline_docs = g_build_filename (ZOITECHATDOCDIR, "index.html", NULL);
if (g_access (offline_docs, R_OK) == 0)
{
fe_open_url (offline_docs);
g_free (offline_docs);
return;
}
g_free (offline_docs);
online = TRUE;
monitor = g_network_monitor_get_default ();
if (monitor)
online = g_network_monitor_get_network_available (monitor);
if (online)
fe_open_url ("https://docs.zoitechat.org/en/latest/");
fe_open_url ("https://docs.zoitechat.org/en/latest/");
}
/*static void

View File

@@ -9,7 +9,6 @@
#define PACKAGE_VERSION "<#= [string]::Join('.', $versionParts) #>"
#define ZOITECHATLIBDIR ".\\plugins"
#define ZOITECHATSHAREDIR "."
#define ZOITECHATDOCDIR "offline-docs"
#define OLD_PERL
#define GETTEXT_PACKAGE "zoitechat"
#define PACKAGE_TARNAME "zoitechat-<#= [string]::Join('.', $versionParts) #>"

View File

@@ -1,6 +1,5 @@
#define APPNAM "ZoiteChat"
#define APPVER "<#= [string]::Join('.', $versionParts) #>"
#define OFFLINEDOCSURL "https://dl.zoitechat.org/offlinedocs/zoitechat-docs-html-" + APPVER + ".tar.gz"
; These are defined by our installer project at build time
;#define APPARCH "x64"
;#define PROJECTDIR "C:\...\zoitechat\win32\installer\"
@@ -50,7 +49,6 @@ Name: "icons"; Description: "Create Shortcuts"; Types: custom; Flags: disablenou
Name: "icons\desktopicon"; Description: "Create Desktop Shortcut"; Types: custom; Flags: disablenouninstallwarning
Name: "icons\quicklaunchicon"; Description: "Create Quick Launch Shortcut"; Types: custom; Flags: disablenouninstallwarning
Name: "translations"; Description: "Translations"; Types: normal custom; Flags: disablenouninstallwarning
Name: "docs"; Description: "Offline Documentation"; Types: normal minimal custom; Flags: disablenouninstallwarning
Name: "spell"; Description: "Spelling Dictionaries"; Types: custom; Flags: disablenouninstallwarning
Name: "plugins"; Description: "Plugins"; Types: custom; Flags: disablenouninstallwarning
Name: "plugins\checksum"; Description: "Checksum"; Types: custom; Flags: disablenouninstallwarning
@@ -97,7 +95,6 @@ Filename: "{sys}\WindowsPowerShell\v1.0\powershell.exe"; Parameters: "-NoProfile
[Dirs]
Name: "{userappdata}\ZoiteChat\gtk3-themes"; Components: themes
Name: "{app}\offline-docs"; Components: docs
[Files]
Source: "portable-mode"; DestDir: "{app}"; Tasks: portable
@@ -108,7 +105,6 @@ Source: "cert.pem"; DestDir: "{app}"; Flags: ignoreversion; Components: libs
Source: "share\xml\*"; DestDir: "{app}\share\xml"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: libs
Source: "share\doc\zoitechat\*"; DestDir: "{app}\share\doc\zoitechat"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: libs
Source: "share\doc\WinSparkle\*"; DestDir: "{app}\share\doc\WinSparkle"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: libs
Source: "offline-docs\*"; DestDir: "{app}\offline-docs"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: docs
Source: "share\themes\MS-Windows\*"; DestDir: "{app}\share\themes\MS-Windows"; Flags: ignoreversion createallsubdirs recursesubdirs skipifsourcedoesntexist; Components: libs
Source: "share\glib-2.0\schemas\*"; DestDir: "{app}\share\glib-2.0\schemas"; Flags: ignoreversion createallsubdirs recursesubdirs skipifsourcedoesntexist; Components: libs
Source: "share\icons\hicolor\*"; DestDir: "{app}\share\icons\hicolor"; Flags: ignoreversion createallsubdirs recursesubdirs skipifsourcedoesntexist; Components: libs
@@ -318,34 +314,7 @@ begin
end;
function InstallOfflineDocs(): Boolean;
var
Archive: String;
DocsDir: String;
ResultCode: Integer;
Script: String;
WorkDir: String;
begin
Result := True;
Archive := ExpandConstant('{tmp}\offline-docs.tar.gz');
DocsDir := ExpandConstant('{app}\offline-docs');
WorkDir := ExpandConstant('{tmp}\offline-docs-extract');
if not FileExists(Archive) then
Exit;
Script := 'Remove-Item -LiteralPath ''' + WorkDir + ''' -Recurse -Force -ErrorAction SilentlyContinue; ' +
'New-Item -ItemType Directory -LiteralPath ''' + WorkDir + ''' -Force | Out-Null; ' +
'tar -xzf ''' + Archive + ''' -C ''' + WorkDir + '''; ' +
'$i = Get-ChildItem -LiteralPath ''' + WorkDir + ''' -Recurse -Filter index.html | Select-Object -First 1; ' +
'if (-not $i) { exit 1 }; ' +
'Remove-Item -LiteralPath ''' + DocsDir + ''' -Recurse -Force -ErrorAction SilentlyContinue; ' +
'New-Item -ItemType Directory -LiteralPath ''' + DocsDir + ''' -Force | Out-Null; ' +
'Copy-Item -Path (Join-Path $i.DirectoryName ''*'') -Destination ''' + DocsDir + ''' -Recurse -Force';
if not Exec(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'), '-NoProfile -ExecutionPolicy Bypass -Command "' + Script + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
Result := False
else
Result := ResultCode = 0;
end;
/////////////////////////////////////////////////////////////////////
function CheckSpellInstall(): Boolean;
var
Version: TWindowsVersion;
@@ -382,9 +351,6 @@ begin
if IsComponentSelected('themes\windows10dark') then
idpAddFile('https://dl.zoitechat.zoite.net/themes/GTK3Themes/Windows-10-Dark-3.2.1-dark.zip', ExpandConstant('{tmp}\Windows-10-Dark-3.2.1-dark.zip'));
if IsComponentSelected('docs') then
idpAddFile('{#OFFLINEDOCSURL}', ExpandConstant('{tmp}\offline-docs.tar.gz'));
if not IsTaskSelected('portable') then
begin
@@ -453,13 +419,6 @@ begin
Exit;
end;
if IsComponentSelected('docs') and not FileExists(ExpandConstant('{tmp}\offline-docs.tar.gz')) then
begin
MsgBox('Offline documentation could not be downloaded. Please retry setup or rerun setup with Offline Documentation deselected.', mbError, MB_OK);
Result := False;
Exit;
end;
if IsComponentSelected('deps\vcredist2015') and not CheckVCInstall() and not FileExists(ExpandConstant('{tmp}\vcredist.exe')) then
begin
MsgBox('Visual C++ Redistributable could not be downloaded. Please retry setup or install it manually and rerun setup.', mbError, MB_OK);
@@ -538,10 +497,4 @@ begin
DeleteFile(ExpandConstant('{app}\portable-mode'));
end;
end;
if (CurStep=ssPostInstall) and IsComponentSelected('docs') then
begin
if not InstallOfflineDocs() then
MsgBox('Offline documentation could not be installed from the downloaded archive.', mbError, MB_OK);
end;
end;