Skip to content

Commit e5b3188

Browse files
[Gtk] Restore cross-compilation for Windows
1 parent e1fad70 commit e5b3188

17 files changed

+57
-25
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ IF("${INTERFACE_TYPE}" STREQUAL "gtk")
128128
ENDIF()
129129
ENDIF()
130130
PKG_CHECK_MODULES(FONTCONFIG REQUIRED fontconfig)
131-
PKG_CHECK_MODULES(UUID REQUIRED uuid)
132131
INCLUDE_DIRECTORIES(
133132
${GTKMM_INCLUDE_DIRS}
134133
${GTKSOURCEVIEWMM_INCLUDE_DIRS}
@@ -141,7 +140,6 @@ IF("${INTERFACE_TYPE}" STREQUAL "gtk")
141140
${LIBJPEG_INCLUDE_DIRS}
142141
${FONTCONFIG_INCLUDE_DIRS}
143142
${LIBZIP_INCLUDE_DIRS}
144-
${UUID_INCLUDE_DIRS}
145143
)
146144
SET(gimagereader_LIBS
147145
${GTKMM_LDFLAGS}
@@ -155,7 +153,6 @@ IF("${INTERFACE_TYPE}" STREQUAL "gtk")
155153
${LIBJPEG_LDFLAGS}
156154
${FONTCONFIG_LDFLAGS}
157155
${LIBZIP_LDFLAGS}
158-
${UUID_LDFLAGS}
159156
)
160157
SET(srcdir "gtk")
161158
ELSEIF("${INTERFACE_TYPE}" STREQUAL "qt5")

gtk/src/Config.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ std::string Config::tessdataLocation(Location location) {
239239
if(location == SystemLocation) {
240240
#ifdef G_OS_WIN32
241241
std::string dataDir = Glib::build_filename(pkgDir, "share");
242-
Glib::setenv("TESSDATA_PREFIX", Glib::build_filename(dataDir, "tessdata");
242+
Glib::setenv("TESSDATA_PREFIX", Glib::build_filename(dataDir, "tessdata"));
243243
#else
244244
Glib::unsetenv("TESSDATA_PREFIX");
245245
#endif

gtk/src/FileDialogs.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <gdk/gdkwin32.h>
2828
#include <windows.h>
2929
#include <locale>
30+
#include <shlobj.h>
3031
#else
3132
#include <gdk/gdkx.h>
3233
#endif
@@ -120,12 +121,15 @@ static std::string win32_open_folder_dialog(const Glib::ustring& title, const st
120121
binfo.iImage = 0;
121122
PIDLIST_ABSOLUTE result = SHBrowseForFolderW(&binfo);
122123
if(result == NULL) {
124+
// ToDo: shouldn't we release the memory hold by "result"?...
123125
return std::string();
124126
}
125-
wchar_t buffer[MAX_PATH];
126-
if(SHGetPathFromIDList(pidl, buffer)) {
127-
return ws2s(buffer);
127+
TCHAR buffer[MAX_PATH];
128+
if(SHGetPathFromIDList(result, buffer)) {
129+
// ToDo: shouldn't we release the memory hold by "result"?...
130+
return std::string(buffer);
128131
}
132+
// ToDo: shouldn't we release the memory hold by "result"?...
129133
return std::string();
130134
}
131135

gtk/src/FileTreeModel.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void FileTreeModel::recursive_row_inserted(const Gtk::TreeIter& index) {
4646

4747
Gtk::TreeIter FileTreeModel::insertFile(std::string filePath, DataObject* data, const Glib::ustring& displayName) {
4848
#ifdef G_OS_WIN32
49-
std::string fileDir = std::string("/") + Glib::path_get_dirname(filePath);
49+
Glib::ustring fileDir = std::string("/") + Glib::path_get_dirname(filePath);
5050
Utils::string_replace(fileDir, "\\", "/", true);
5151
filePath = std::string("/") + filePath;
5252
std::string tempPath = std::string("/") + Glib::get_tmp_dir();
@@ -182,7 +182,7 @@ Gtk::TreeIter FileTreeModel::findFile(const std::string& filePath, bool isFile)
182182

183183
#ifdef G_OS_WIN32
184184
std::string prefix = "/";
185-
std::string fileDir = std::string("/") + Glib::path_get_dirname(filePath);
185+
Glib::ustring fileDir = std::string("/") + Glib::path_get_dirname(filePath);
186186
Utils::string_replace(fileDir, "\\", "/", true);
187187
std::string tempPath = std::string("/") + Glib::get_tmp_dir();
188188
#else

gtk/src/Utils.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
#include <clocale>
2626
#include <csignal>
2727
#include <fontconfig/fontconfig.h>
28+
29+
#ifdef G_OS_WIN32
30+
#include <windows.h>
31+
#endif
32+
2833
#define USE_STD_NAMESPACE
2934
#include <tesseract/baseapi.h>
3035
#undef USE_STD_NAMESPACE
@@ -192,9 +197,11 @@ std::string Utils::make_absolute_path(const std::string& path, const std::string
192197
return path;
193198
}
194199
std::string abspath = Glib::build_filename(basepath, path);
200+
#ifdef G_OS_UNIX
195201
char* realabspath = realpath(abspath.c_str(), nullptr);
196202
abspath = std::string(realabspath);
197203
free(realabspath);
204+
#endif
198205
return abspath;
199206
}
200207

gtk/src/hocr/HOCROdtExporter.cc

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <cstring>
3030
#include <iomanip>
3131
#include <libxml++/libxml++.h>
32-
#include <uuid/uuid.h>
32+
#include <glib/guuid.h>
3333
#include <zip.h>
3434

3535
static Glib::ustring manifestNS_URI("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0");
@@ -352,18 +352,12 @@ void HOCROdtExporter::writeImage(zip* fzip, std::map<const HOCRItem*, Glib::ustr
352352
if(item->itemClass() == "ocr_graphic") {
353353
Cairo::RefPtr<Cairo::ImageSurface> selection;
354354
Utils::runInMainThreadBlocking([&] { selection = getSelection(item->bbox()); });
355-
//#if GLIB_CHECK_VERSION(2, 52, 0)
356-
// gchar* guuid = g_uuid_string_random();
357-
// Glib::ustring uuid(guuid);
358-
// g_free(guuid);
359-
// uuid = uuid.substr(1, uuid.length() - 2); // Remove {}
360-
//#else
361-
uuid_t uuidGenerated;
362-
uuid_generate_random(uuidGenerated);
363-
char uuidBuff[36];
364-
uuid_unparse(uuidGenerated, uuidBuff);
365-
Glib::ustring uuid(uuidBuff);
366-
//#endif
355+
356+
gchar* guuid = g_uuid_string_random();
357+
Glib::ustring uuid(guuid);
358+
g_free(guuid);
359+
uuid = uuid.substr(1, uuid.length() - 2); // Remove {}
360+
367361
Glib::ustring filename = Glib::ustring::compose("Pictures/%1.png", uuid);
368362

369363
Glib::RefPtr<Glib::ByteArray> pngbytes = Glib::ByteArray::create();

packaging/win32/Dockerfile

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ FROM fedora:rawhide
22

33
MAINTAINER Sandro Mani <[email protected]>
44

5+
RUN dnf -y update; dnf clean all
6+
57
RUN \
68
echo all > /etc/rpm/macros.image-language-conf && \
79
dnf install -y \
@@ -16,6 +18,7 @@ dnf install -y \
1618
tesseract \
1719
mingw32-nsis \
1820
zip \
21+
python3-gobject \
1922
\
2023
mingw32-gdb \
2124
mingw32-gcc-c++ \
@@ -34,6 +37,19 @@ dnf install -y \
3437
mingw32-twaindsm \
3538
mingw32-quazip-qt5 \
3639
\
40+
mingw32-libzip \
41+
mingw32-gtk3 gtk3 gtk3-devel \
42+
mingw32-glib2-static glib2 glib2-devel \
43+
mingw32-gtkmm30 \
44+
mingw32-gtkspell3 \
45+
mingw32-gtkspellmm30 \
46+
mingw32-gtksourceviewmm3 \
47+
mingw32-cairomm \
48+
mingw32-poppler \
49+
mingw32-poppler-glib \
50+
mingw32-json-glib \
51+
mingw32-libxml++ \
52+
\
3753
mingw64-gdb \
3854
mingw64-gcc-c++ \
3955
mingw64-dlfcn \
@@ -49,7 +65,21 @@ dnf install -y \
4965
mingw64-qtspell-qt5 \
5066
mingw64-tesseract \
5167
mingw64-twaindsm \
52-
mingw64-quazip-qt5
68+
mingw64-quazip-qt5 \
69+
\
70+
mingw64-libzip \
71+
mingw64-gtk3 gtk3 gtk3-devel \
72+
mingw64-glib2-static glib2 glib2-devel \
73+
mingw64-gtkmm30 \
74+
mingw64-gtkspell3 \
75+
mingw64-gtkspellmm30 \
76+
mingw64-gtksourceviewmm3 \
77+
mingw64-cairomm \
78+
mingw64-poppler \
79+
mingw64-poppler-glib \
80+
mingw64-json-glib \
81+
mingw64-libxml++
82+
5383

5484
WORKDIR /workspace
55-
VOLUME ["/workspace"]
85+
VOLUME ["/workspace"]

packaging/win32/makeinstaller.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,4 @@ makensis -DNAME=$progName -DARCH=$arch -DVARIANT="$variant" -DPROGVERSION="$prog
217217
# Cleanup
218218
rm -rf $installroot
219219

220-
echo "Installer written to $PWD/${progName}_${progVersion}_${iface}_${arch}.exe"
220+
echo "Installer written to $PWD/${progName}_${progVersion}_${iface}_${arch}.exe"
198 Bytes
Loading
195 Bytes
Loading

0 commit comments

Comments
 (0)