Skip to content

Commit 2b2d96d

Browse files
authored
Windows build and installer
1 parent 54ecfe8 commit 2b2d96d

27 files changed

+739
-43
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ generate_stylesheets.sh
1010
.flatpak/
1111
.potrans
1212
.editorconfig
13-
oldpng/
13+
oldpng/
14+
deploy/

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ flatpak run io.github.ellie_commons.jorts --preferences
3737

3838
Theres none. The app closes on its own when no window is open. Doesn't make sense to use resources if unused.
3939

40+
If you want to quit everything at once, use Ctrl+Q
41+
4042

4143
### Where close note
4244

data/meson.build

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,53 @@ install_data (
55
rename: meson.project_name() + '.gschema.xml'
66
)
77

8-
#======== Internationalization ========
9-
#Translate and install our .desktop file
10-
i18n.merge_file(
11-
input: 'jorts.desktop.in',
12-
output: meson.project_name() + '.desktop',
13-
po_dir: meson.project_source_root() / 'po' / 'extra',
14-
type: 'desktop',
15-
install: true,
16-
install_dir: get_option('datadir') / 'applications'
17-
)
8+
# metainfo confuses windows, and icons are
9+
if not windows_build
1810

19-
#Translate and install our .metainfo file
20-
i18n.merge_file(
21-
input: 'jorts.metainfo.xml.in',
22-
output: meson.project_name() + '.metainfo.xml',
23-
po_dir: meson.project_source_root() / 'po' / 'extra',
24-
install: true,
25-
install_dir: get_option('datadir') / 'metainfo'
26-
)
11+
#======== Internationalization ========
12+
#Translate and install our .desktop file
13+
i18n.merge_file(
14+
input: 'jorts.desktop.in',
15+
output: meson.project_name() + '.desktop',
16+
po_dir: meson.project_source_root() / 'po' / 'extra',
17+
type: 'desktop',
18+
install: true,
19+
install_dir: get_option('datadir') / 'applications'
20+
)
2721

22+
#======== Metainfo ========
23+
#Translate and install our .metainfo file
24+
i18n.merge_file(
25+
input: 'jorts.metainfo.xml.in',
26+
output: meson.project_name() + '.metainfo.xml',
27+
po_dir: meson.project_source_root() / 'po' / 'extra',
28+
install: true,
29+
install_dir: get_option('datadir') / 'metainfo'
30+
)
2831

29-
#======== ICONS ========
32+
#======== ICONS ========
33+
# Install our icons in all the required sizes
34+
# "variant" variable has been declared earlier in the base meson
35+
icon_sizes = ['16', '24', '32', '48', '64', '128']
3036

31-
# Install our icons in all the required sizes
32-
# "variant" variable has been declared earlier in the base meson
33-
icon_sizes = ['16', '24', '32', '48', '64', '128']
37+
foreach i : icon_sizes
38+
install_data(
39+
'icons' / variant / 'hicolor' / i + '.png',
40+
install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i / 'apps',
41+
rename: meson.project_name() + '.png'
42+
)
43+
install_data(
44+
'icons' / variant / 'hicolor@2' / i + '@2.png',
45+
install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i + '@2' / 'apps',
46+
rename: meson.project_name() + '.png'
47+
)
48+
endforeach
3449

35-
foreach i : icon_sizes
3650
install_data(
37-
'icons' / variant / 'hicolor' / i + '.png',
38-
install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i / 'apps',
39-
rename: meson.project_name() + '.png'
51+
'icons' / variant / 'scalable.svg',
52+
install_dir: get_option('datadir') / 'icons' / 'scalable' / 'apps',
53+
rename: meson.project_name() + '.svg'
4054
)
41-
install_data(
42-
'icons' / variant / 'hicolor@2' / i + '@2.png',
43-
install_dir: get_option('datadir') / 'icons' / 'hicolor' / i + 'x' + i + '@2' / 'apps',
44-
rename: meson.project_name() + '.png'
45-
)
46-
endforeach
4755

48-
install_data(
49-
'icons' / variant / 'scalable.svg',
50-
install_dir: get_option('datadir') / 'icons' / 'scalable' / 'apps',
51-
rename: meson.project_name() + '.svg'
52-
)
56+
endif
57+

meson.build

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ i18n = import('i18n')
88

99
add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()), language:'c')
1010

11+
if build_machine.system() == 'windows'
12+
windows_build = true
13+
else
14+
windows_build = false
15+
endif
16+
1117

1218
vala_flags = []
1319
variant = get_option('variant')[0]
@@ -20,9 +26,17 @@ else
2026
vala_flags = ['--define', 'DEFAULT']
2127
endif
2228

23-
add_project_arguments(vala_flags, language: 'vala')
29+
30+
if windows_build
31+
vala_flags += ['--define', 'WINDOWS']
32+
endif
33+
2434

2535

36+
37+
38+
add_project_arguments(vala_flags, language: 'vala')
39+
2640
#================================
2741
# Import the stylesheet
2842

@@ -49,10 +63,16 @@ dependencies = [
4963
dependency('json-glib-1.0'),
5064
dependency('gee-0.8'),
5165
dependency('gtk4'),
52-
dependency('libportal')
5366
]
5467

68+
if windows_build
69+
dependencies += dependency('gio-windows-2.0')
70+
ico_src = import('windows').compile_resources('windows/icons/ico.rc')
5571

72+
else
73+
dependencies += dependency('gio-unix-2.0')
74+
dependencies += dependency('libportal')
75+
endif
5676

5777
#================================
5878

src/Services/Storage.vala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ public class Jorts.Storage : Object {
3030

3131
/*************************************************/
3232
construct {
33+
34+
#if WINDOWS
35+
// In Windows we arent in a sandbox, so we need to have some courtesy and not dump in the allfolder
36+
data_directory = GLib.Path.build_path("/", Environment.get_user_data_dir (), "io.github.ellie_commons.jorts");
37+
#else
3338
data_directory = Environment.get_user_data_dir ();
39+
#endif
40+
3441
storage_path = data_directory + "/" + FILENAME;
3542
check_if_stash ();
3643
}

src/Views/PreferencesView.vala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
/****************************************************/
8585
/* Autostart Request */
8686
/****************************************************/
87+
#if !WINDOWS
8788

8889
Xdp.Portal portal = new Xdp.Portal ();
8990
GenericArray<weak string> cmd = new GenericArray<weak string> ();
@@ -148,7 +149,7 @@
148149
autostart_box.append (autostart_label);
149150
autostart_box.append (both_buttons);
150151
settingsbox.append (autostart_box);
151-
152+
#endif
152153
/*************************************************/
153154
// Bar at the bottom
154155
var actionbar = new Gtk.CenterBox () {

src/Windows/StickyNoteWindow.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
149149
* This is more for the Aesthetic
150150
*/
151151
private void delayed_show () {
152-
Timeout.add_once (750, () => {
152+
Timeout.add_once (250, () => {
153153
Application.gsettings.bind (
154154
"hide-bar",
155155
view.actionbar.actionbar,

src/meson.build

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ sources = files (
55

66
'Utils' / 'ZoomConvert.vala',
77
'Utils' / 'Random.vala',
8-
'Utils' / 'Libportal.vala',
98

109
'Services' / 'Constants.vala',
1110
'Services' / 'Storage.vala',
@@ -31,13 +30,22 @@ sources = files (
3130
'Application.vala',
3231
)
3332

33+
if windows_build
34+
sources += ico_src
35+
else
36+
sources += files('Utils' / 'Libportal.vala')
37+
endif
38+
3439
#================================
3540
# Let's define our executable
41+
# win_subsystem doesnt seem to bother standard builds
42+
3643
executable(
3744
meson.project_name(),
3845
gresource,
3946
config_file,
4047
sources,
4148
dependencies: dependencies,
49+
win_subsystem: 'windows',
4250
install : true
4351
)

windows/Jorts-Installer.exe

46.9 MB
Binary file not shown.

windows/Jorts-Installer.nsi

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
!include "MUI2.nsh"
2+
!include WinMessages.nsh
3+
4+
Name Jorts
5+
6+
Outfile "Jorts-Installer.exe"
7+
InstallDir "$LOCALAPPDATA\Programs\Jorts"
8+
9+
# RequestExecutionLevel admin ; Request administrative privileges
10+
RequestExecutionLevel user
11+
12+
# Set the title of the installer window
13+
Caption "Jorts Installer"
14+
15+
# Set the title and text on the welcome page
16+
!define MUI_WELCOMEPAGE_TITLE "Welcome to Jorts setup"
17+
!define MUI_WELCOMEPAGE_TEXT "This bitch will guide you through the installation of Jorts."
18+
!define MUI_INSTFILESPAGE_TEXT "Please wait while Jorts is being installed."
19+
!define MUI_ICON "icons\install.ico"
20+
!define MUI_UNICON "icons\uninstall.ico"
21+
!define MUI_FINISHPAGE_RUN "$SMPROGRAMS\Startup\Jorts.lnk"
22+
23+
!insertmacro MUI_PAGE_WELCOME
24+
!insertmacro MUI_PAGE_DIRECTORY
25+
!insertmacro MUI_PAGE_INSTFILES
26+
!insertmacro MUI_PAGE_FINISH
27+
!insertmacro MUI_UNPAGE_CONFIRM
28+
!insertmacro MUI_UNPAGE_INSTFILES
29+
!insertmacro MUI_UNPAGE_FINISH
30+
31+
!insertmacro MUI_LANGUAGE "English"
32+
33+
!macro GetCleanDir INPUTDIR
34+
; ATTENTION: USE ON YOUR OWN RISK!
35+
; Please report bugs here: http://stefan.bertels.org/
36+
!define Index_GetCleanDir 'GetCleanDir_Line${__LINE__}'
37+
Push $R0
38+
Push $R1
39+
StrCpy $R0 "${INPUTDIR}"
40+
StrCmp $R0 "" ${Index_GetCleanDir}-finish
41+
StrCpy $R1 "$R0" "" -1
42+
StrCmp "$R1" "\" ${Index_GetCleanDir}-finish
43+
StrCpy $R0 "$R0\"
44+
${Index_GetCleanDir}-finish:
45+
Pop $R1
46+
Exch $R0
47+
!undef Index_GetCleanDir
48+
!macroend
49+
50+
; ################################################################
51+
; similar to "RMDIR /r DIRECTORY", but does not remove DIRECTORY itself
52+
; example: !insertmacro RemoveFilesAndSubDirs "$INSTDIR"
53+
!macro RemoveFilesAndSubDirs DIRECTORY
54+
; ATTENTION: USE ON YOUR OWN RISK!
55+
; Please report bugs here: http://stefan.bertels.org/
56+
!define Index_RemoveFilesAndSubDirs 'RemoveFilesAndSubDirs_${__LINE__}'
57+
58+
Push $R0
59+
Push $R1
60+
Push $R2
61+
62+
!insertmacro GetCleanDir "${DIRECTORY}"
63+
Pop $R2
64+
FindFirst $R0 $R1 "$R2*.*"
65+
${Index_RemoveFilesAndSubDirs}-loop:
66+
StrCmp $R1 "" ${Index_RemoveFilesAndSubDirs}-done
67+
StrCmp $R1 "." ${Index_RemoveFilesAndSubDirs}-next
68+
StrCmp $R1 ".." ${Index_RemoveFilesAndSubDirs}-next
69+
IfFileExists "$R2$R1\*.*" ${Index_RemoveFilesAndSubDirs}-directory
70+
; file
71+
Delete "$R2$R1"
72+
goto ${Index_RemoveFilesAndSubDirs}-next
73+
${Index_RemoveFilesAndSubDirs}-directory:
74+
; directory
75+
RMDir /r "$R2$R1"
76+
${Index_RemoveFilesAndSubDirs}-next:
77+
FindNext $R0 $R1
78+
Goto ${Index_RemoveFilesAndSubDirs}-loop
79+
${Index_RemoveFilesAndSubDirs}-done:
80+
FindClose $R0
81+
82+
Pop $R2
83+
Pop $R1
84+
Pop $R0
85+
!undef Index_RemoveFilesAndSubDirs
86+
!macroend
87+
88+
Section "Install"
89+
SetOutPath "$INSTDIR"
90+
File /r "deploy\*"
91+
CreateDirectory $SMPROGRAMS\Jorts
92+
93+
; fonts. We install to local fonts to not trip up admin rights, and register for local user
94+
SetOutPath "$LOCALAPPDATA\Microsoft\Windows\Fonts"
95+
File "fonts\RedactedScript-Regular.ttf"
96+
WriteRegStr HKCU "Software\Microsoft\Windows NT\CurrentVersion\Fonts" "Redacted Script Regular (TrueType)" "$LOCALAPPDATA\Microsoft\Windows\Fonts\RedactedScript-Regular.ttf"
97+
; SendMessage 0 0 /TIMEOUT=5000
98+
99+
; Start menu
100+
CreateShortCut "$SMPROGRAMS\Jorts\Jorts.lnk" "$INSTDIR\bin\io.github.ellie_commons.jorts.exe" "" "$INSTDIR\icons\icon-mini.ico" 0
101+
102+
; Autostart
103+
CreateShortCut "$SMPROGRAMS\Startup\Jorts.lnk" "$INSTDIR\bin\io.github.ellie_commons.jorts.exe" "" "$INSTDIR\icons\icon-mini.ico" 0
104+
105+
; Preferences
106+
CreateShortCut "$SMPROGRAMS\Jorts\Preferences of Jorts.lnk" "$INSTDIR\bin\io.github.ellie_commons.jorts.exe" "--preferences" "$INSTDIR\icons\settings-mini.ico" 0
107+
108+
WriteRegStr HKCU "Software\Jorts" "" $INSTDIR
109+
WriteUninstaller "$INSTDIR\Uninstall.exe"
110+
111+
; Add to Add/Remove programs list
112+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Jorts" "DisplayName" "Jorts"
113+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Jorts" "UninstallString" "$INSTDIR\Uninstall.exe"
114+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Jorts" "InstallLocation" "$INSTDIR\"
115+
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Jorts" "Publisher" "Ellie-Commons"
116+
SectionEnd
117+
118+
Section "Uninstall"
119+
120+
; Remove Start Menu shortcut
121+
Delete "$SMPROGRAMS\Jorts\Jorts.lnk"
122+
Delete "$SMPROGRAMS\Jorts\Preferences of Jorts.lnk"
123+
Delete "$SMPROGRAMS\Startup\Jorts.lnk"
124+
125+
; Remove uninstaller
126+
Delete "$INSTDIR\Uninstall.exe"
127+
128+
; Remove files and folders
129+
!insertmacro RemoveFilesAndSubDirs "$INSTDIR"
130+
131+
; Remove directories used
132+
RMDir $SMPROGRAMS\Jorts
133+
RMDir "$INSTDIR"
134+
135+
; Remove registry keys
136+
DeleteRegKey HKCU "Software\Jorts"
137+
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Jorts"
138+
139+
SectionEnd
140+

0 commit comments

Comments
 (0)