sdgui: rasterize some icons, including for Windows

This commit is contained in:
Přemysl Eric Janouch 2021-10-27 09:48:57 +02:00
parent 0eb935ad9f
commit 46e9b7b584
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 47 additions and 3 deletions

View File

@ -188,10 +188,51 @@ endif (NOT WIN32)
# The same for the alternative GTK+ UI # The same for the alternative GTK+ UI
if (WITH_GUI) if (WITH_GUI)
add_executable (sdgui WIN32 find_program (rsvg_convert_EXECUTABLE rsvg-convert REQUIRED)
set (icon_svg ${PROJECT_SOURCE_DIR}/sdgui.svg)
set (icon_base ${PROJECT_BINARY_DIR}/icons)
set (icon_png_list)
# The largest size is mainly for an appropriately sized Windows icon
foreach (icon_number 16 32 48 256)
set (icon_size ${icon_number}x${icon_number})
set (icon_png_path ${icon_base}/hicolor/${icon_size}/apps)
set (icon_png ${icon_png_path}/sdgui.png)
list (APPEND icon_png_list ${icon_png})
add_custom_command (OUTPUT ${icon_png}
COMMAND ${CMAKE_COMMAND} -E make_directory ${icon_png_path}
COMMAND ${rsvg_convert_EXECUTABLE} --output=${icon_png}
--width=${icon_number} --height=${icon_number} ${icon_svg}
DEPENDS ${icon_svg}
COMMENT "Generating ${icon_size} application icon" VERBATIM)
endforeach (icon_number)
add_custom_target (sdgui-icons ALL DEPENDS ${icon_png_list})
set (sdgui_sources
src/sdgui.c src/sdgui.c
src/stardict-view.c src/stardict-view.c
${project_common_sources}) ${project_common_sources})
if (WIN32)
find_program (icotool_EXECUTABLE icotool REQUIRED)
set (icon_ico ${PROJECT_BINARY_DIR}/sdgui.ico)
add_custom_command (OUTPUT ${icon_ico}
COMMAND ${icotool_EXECUTABLE} -c -o ${icon_ico} ${icon_png_list}
DEPENDS ${icon_png_list}
COMMENT "Generating Windows program icon" VERBATIM)
set (resource_file ${PROJECT_BINARY_DIR}/sdgui.rc)
list (APPEND sdgui_sources ${resource_file})
add_custom_command (OUTPUT ${resource_file}
COMMAND ${CMAKE_COMMAND} -E echo "1 ICON \"sdgui.ico\""
> ${resource_file} VERBATIM)
set_property (SOURCE ${resource_file}
APPEND PROPERTY OBJECT_DEPENDS ${icon_ico})
endif ()
add_executable (sdgui WIN32 ${sdgui_sources})
target_include_directories (sdgui PUBLIC ${gtk_INCLUDE_DIRS}) target_include_directories (sdgui PUBLIC ${gtk_INCLUDE_DIRS})
target_link_libraries (sdgui ${project_common_libraries} ${gtk_LIBRARIES}) target_link_libraries (sdgui ${project_common_libraries} ${gtk_LIBRARIES})
endif () endif ()
@ -231,6 +272,8 @@ if (NOT WIN32)
install (TARGETS sdgui DESTINATION ${CMAKE_INSTALL_BINDIR}) install (TARGETS sdgui DESTINATION ${CMAKE_INSTALL_BINDIR})
install (FILES sdgui.svg install (FILES sdgui.svg
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps) DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
install (DIRECTORY ${PROJECT_BINARY_DIR}/icons
DESTINATION ${CMAKE_INSTALL_DATADIR})
install (FILES sdgui.desktop install (FILES sdgui.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
install (FILES sdgui.xml install (FILES sdgui.xml
@ -266,6 +309,7 @@ elseif (WITH_GUI)
install (FILES install (FILES
${WIN32_DEPENDS_PATH}/share/icons/hicolor/index.theme ${WIN32_DEPENDS_PATH}/share/icons/hicolor/index.theme
DESTINATION share/icons/hicolor) DESTINATION share/icons/hicolor)
install (DIRECTORY ${icon_base} DESTINATION share)
install (SCRIPT cmake/Win32Cleanup.cmake) install (SCRIPT cmake/Win32Cleanup.cmake)
install (CODE "execute_process (COMMAND install (CODE "execute_process (COMMAND

View File

@ -28,10 +28,10 @@ The rest of this README will concern itself with externalities.
Building and Running Building and Running
-------------------- --------------------
Build dependencies: CMake, pkg-config, asciidoctor + Build dependencies: CMake, pkg-config, asciidoctor, librsvg (for the GUI) +
Runtime dependencies: ncursesw, zlib, ICU, termo (included), glib-2.0 >= 2.38, Runtime dependencies: ncursesw, zlib, ICU, termo (included), glib-2.0 >= 2.38,
pango, xcb, xcb-xfixes (the latter two optional for the TUI), pango, xcb, xcb-xfixes (the latter two optional for the TUI),
gtk+-3.0 (for the alternative graphical UI) gtk+-3.0 (for the GUI)
$ git clone --recursive https://git.janouch.name/p/sdtui.git $ git clone --recursive https://git.janouch.name/p/sdtui.git
$ mkdir sdtui/build $ mkdir sdtui/build