Skip to content

Commit

Permalink
[Gtk] Use libuuid, g_uuid_string_random is still too new for some dis…
Browse files Browse the repository at this point in the history
…tros
  • Loading branch information
manisandro committed Feb 24, 2018
1 parent 2b34c06 commit 0a67c5e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ IF("${INTERFACE_TYPE}" STREQUAL "gtk")
ENDIF()
ENDIF()
PKG_CHECK_MODULES(FONTCONFIG REQUIRED fontconfig)
PKG_CHECK_MODULES(UUID REQUIRED uuid)
INCLUDE_DIRECTORIES(
${GTKMM_INCLUDE_DIRS}
${GTKSOURCEVIEWMM_INCLUDE_DIRS}
Expand All @@ -110,6 +111,7 @@ IF("${INTERFACE_TYPE}" STREQUAL "gtk")
${LIBJPEG_INCLUDE_DIRS}
${FONTCONFIG_INCLUDE_DIRS}
${LIBZIP_INCLUDE_DIRS}
${UUID_INCLUDE_DIRS}
)
SET(gimagereader_LIBS
${GTKMM_LDFLAGS}
Expand All @@ -124,6 +126,7 @@ IF("${INTERFACE_TYPE}" STREQUAL "gtk")
${PODOFO_LDFLAGS}
${FONTCONFIG_LDFLAGS}
${LIBZIP_LDFLAGS}
${UUID_LDFLAGS}
)
SET(srcdir "gtk")
ELSEIF("${INTERFACE_TYPE}" STREQUAL "qt4")
Expand Down
17 changes: 13 additions & 4 deletions gtk/src/hocr/HOCROdtExporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <cstring>
#include <iomanip>
#include <libxml++/libxml++.h>
#include <uuid.h>
#include <zip.h>

static Glib::ustring manifestNS_URI("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0");
Expand Down Expand Up @@ -352,10 +353,18 @@ void HOCROdtExporter::writeImage(zip* fzip, std::map<const HOCRItem*, Glib::ustr
if(item->itemClass() == "ocr_graphic") {
Cairo::RefPtr<Cairo::ImageSurface> selection;
Utils::runInMainThreadBlocking([&] { selection = getSelection(item->bbox()); });
gchar* guuid = g_uuid_string_random();
Glib::ustring uuid(guuid);
uuid = uuid.substr(1, uuid.length() - 2); // Remove {}
g_free(guuid);
//#if GLIB_CHECK_VERSION(2, 52, 0)
// gchar* guuid = g_uuid_string_random();
// Glib::ustring uuid(guuid);
// g_free(guuid);
// uuid = uuid.substr(1, uuid.length() - 2); // Remove {}
//#else
uuid_t uuidGenerated;
uuid_generate_random(uuidGenerated);
char uuidBuff[36];
uuid_unparse(uuidGenerated, uuidBuff);
Glib::ustring uuid(uuidBuff);
//#endif
Glib::ustring filename = Glib::ustring::compose("Pictures/%1.png", uuid);

Glib::RefPtr<Glib::ByteArray> pngbytes = Glib::ByteArray::create();
Expand Down
3 changes: 2 additions & 1 deletion packaging/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Build-Depends: debhelper (>= 9),
libquazip5-dev,
libquazip5-headers,
libzip-dev,
python3-gi
python3-gi,
uuid-dev
Standards-Version: 3.9.4
Homepage: https://github.com/manisandro/gImageReader

Expand Down
35 changes: 20 additions & 15 deletions packaging/gimagereader.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,33 @@ License: GPLv3+
URL: https://github.com/manisandro/gImageReader
Source0: https://github.com/manisandro/gImageReader/releases/download/v%{version}/%{name}-%{version}.tar.xz

BuildRequires: gcc-c++
BuildRequires: desktop-file-utils
BuildRequires: djvulibre-devel
BuildRequires: cmake
BuildRequires: gcc-c++
BuildRequires: intltool
BuildRequires: make
BuildRequires: podofo-devel
BuildRequires: sane-backends-devel
BuildRequires: tesseract-devel

BuildRequires: cairomm-devel
BuildRequires: libappstream-glib
BuildRequires: libjpeg-turbo-devel
BuildRequires: libxml++30-devel
BuildRequires: libuuid-devel
BuildRequires: libzip-devel
BuildRequires: gtkmm30-devel
BuildRequires: gtkspellmm30-devel
BuildRequires: gtksourceviewmm3-devel
BuildRequires: cairomm-devel
BuildRequires: gtkspellmm30-devel
BuildRequires: json-glib-devel
BuildRequires: poppler-glib-devel
BuildRequires: tesseract-devel
BuildRequires: sane-backends-devel
BuildRequires: intltool
BuildRequires: desktop-file-utils
BuildRequires: libappstream-glib
BuildRequires: python3-gobject

BuildRequires: poppler-qt5-devel
BuildRequires: qt5-qtbase-devel
BuildRequires: qtspell-qt5-devel
BuildRequires: poppler-qt5-devel
BuildRequires: json-glib-devel
BuildRequires: libxml++30-devel
BuildRequires: podofo-devel
BuildRequires: djvulibre-devel
BuildRequires: quazip-qt5-devel
BuildRequires: libzip-devel
BuildRequires: python3-gobject

Requires: hicolor-icon-theme

Expand Down

0 comments on commit 0a67c5e

Please sign in to comment.