Compare commits

..

No commits in common. "master" and "v0.1.1" have entirely different histories.

112 changed files with 4548 additions and 6526 deletions

View File

@ -1,38 +0,0 @@
# clang-format is fairly limited, and these rules are approximate:
# - array initializers can get terribly mangled with clang-format 12.0,
# - sometimes it still aligns with space characters,
# - struct name NL { NL ... NL } NL name; is unachievable.
BasedOnStyle: GNU
ColumnLimit: 80
IndentWidth: 4
TabWidth: 4
UseTab: ForContinuationAndIndentation
BreakBeforeBraces: Allman
SpaceAfterCStyleCast: true
AlignConsecutiveAssignments: true
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlines: DontAlign
AlignOperands: DontAlign
AlignConsecutiveMacros: Consecutive
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
IndentGotoLabels: false
Cpp11BracedListStyle: true
MaxEmptyLinesToKeep: 2
# IncludeCategories has some potential, but currently it breaks build.
# Note that the documentation says the value should be "Never".
SortIncludes: false
# Must be kept synchronized with gi18n.h and make-template.sh.
WhitespaceSensitiveMacros: ['_', 'Q_', 'N_', 'C_', 'NC_']
# This is a compromise, it generally works out aesthetically better.
BinPackArguments: false
# Unfortunately, this doesn't work for block comments, used in logdiag.
SpacesBeforeTrailingComments: 2
# logdiag-specific function body wrappers.
MacroBlockBegin: "LD_LUA_CAIRO_BEGIN"
MacroBlockEnd: "LD_LUA_CAIRO_END"

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
/build /build
/win32-depends /win32-depends
/CMakeLists.txt.user /liblogdiag/ld-marshal.[ch]

View File

@ -1,54 +1,76 @@
# The last version with Windows XP support is 3.13, we want to keep that project (logdiag C)
cmake_minimum_required (VERSION 3.10) cmake_minimum_required (VERSION 2.6.2)
project (logdiag VERSION 0.3.0 DESCRIPTION "Schematic editor" LANGUAGES C)
# Default to 2.6.3 behaviour
cmake_policy (VERSION 2.6.3)
# Options # Options
option (OPTION_CLANG_TIDY "Enable use of clang-tidy" OFF) option (OPTION_NOINSTALL "Only for developers; work without installing" OFF)
option (OPTION_NOINSTALL "For developers only--work without installing" OFF)
option (OPTION_GTKDOC "For developers only--enable use of gtk-doc" OFF) if (OPTION_NOINSTALL)
option (BUILD_TESTING "Build tests" OFF) set (OPTION_NOINSTALL 1)
else (OPTION_NOINSTALL)
set (OPTION_NOINSTALL 0)
endif (OPTION_NOINSTALL)
# Project information # Project information
set (project_ID "name.janouch.${PROJECT_NAME}") set (project_VERSION_MAJOR "0")
set (project_URL "https://git.janouch.name/p/logdiag") set (project_VERSION_MINOR "1")
set (project_VERSION_PATCH "1")
set (project_VERSION "${project_VERSION_MAJOR}")
set (project_VERSION "${project_VERSION}.${project_VERSION_MINOR}")
set (project_VERSION "${project_VERSION}.${project_VERSION_PATCH}")
set (project_URL "http://github.com/pjanouch/logdiag")
# For custom modules # For custom modules
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Test this machine
include (CheckCSourceCompiles)
CHECK_C_SOURCE_COMPILES (
"typedef struct abc *d;
int test (d __restrict x);
int main (void) {return 0;}"
HAVE_SANE___RESTRICT)
CHECK_C_SOURCE_COMPILES (
"int test (void *restrict x);
int main (void) {return 0;}"
HAVE_RESTRICT)
# Automatic retrieval of dependencies # Automatic retrieval of dependencies
if (WIN32) if (WIN32)
set (WIN32_DEPENDS_PATH ${PROJECT_SOURCE_DIR}/win32-depends) set (WIN32_DEPENDS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/win32-depends)
list (APPEND CMAKE_PREFIX_PATH ${WIN32_DEPENDS_PATH}) list (APPEND CMAKE_PREFIX_PATH ${WIN32_DEPENDS_PATH})
list (APPEND CMAKE_INCLUDE_PATH ${WIN32_DEPENDS_PATH}/lib) list (APPEND CMAKE_INCLUDE_PATH ${WIN32_DEPENDS_PATH}/lib)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mms-bitfields") list (APPEND CMAKE_C_FLAGS "-mms-bitfields")
if (CMAKE_CROSSCOMPILING) add_custom_target (win32-depends COMMAND ${CMAKE_COMMAND} -P
list (APPEND CMAKE_FIND_ROOT_PATH ${WIN32_DEPENDS_PATH}) ${CMAKE_CURRENT_SOURCE_DIR}/Win32Depends.cmake
endif () WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target (win32-depends-clean COMMAND ${CMAKE_COMMAND} -E
set (PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE) remove_directory ${WIN32_DEPENDS_PATH})
# Seems like there is a regression setting this to two paths in one, endif (WIN32)
# setting the path manually
set (ENV{PKG_CONFIG_PATH} "${WIN32_DEPENDS_PATH}/lib/pkgconfig")
endif ()
# Generate icons # Generate icons
find_program (CONVERT_EXECUTABLE convert) find_program (CONVERT_EXECUTABLE convert)
mark_as_advanced (CONVERT_EXECUTABLE) mark_as_advanced (CONVERT_EXECUTABLE)
if (CONVERT_EXECUTABLE AND NOT WIN32) if (CONVERT_EXECUTABLE AND NOT WIN32)
set (icon_base ${PROJECT_SOURCE_DIR}/share/icons/hicolor) set (icon_base ${CMAKE_CURRENT_SOURCE_DIR}/share/icons/hicolor)
set (icon_svg ${icon_base}/scalable/apps/logdiag.svg) set (icon_svg ${icon_base}/scalable/apps/logdiag.svg)
set (icon_size_list 16x16 32x32 48x48) set (icon_size_list 16x16 32x32 48x48)
# ImageMagick very oddly outperforms rsvg-convert with our specific SVG
set (icon_png_list) set (icon_png_list)
set (icon_symbolic_list) set (icon_symbolic_list)
foreach (icon_size ${icon_size_list}) foreach (icon_size ${icon_size_list})
set (icon_png_path ${icon_base}/${icon_size}/apps) set (icon_png_path ${icon_base}/${icon_size}/apps)
set (icon_png ${icon_png_path}/logdiag.png) set (icon_png ${icon_png_path}/logdiag.png)
list (APPEND icon_png_list ${icon_png}) list (APPEND icon_png_list ${icon_png})
set (icon_symbolic ${PROJECT_NAME}_icons_${icon_size}) set (icon_symbolic logdiag_icons_${icon_size})
list (APPEND icon_symbolic_list ${icon_symbolic}) list (APPEND icon_symbolic_list ${icon_symbolic})
add_custom_command (OUTPUT ${icon_symbolic} add_custom_command (OUTPUT ${icon_symbolic}
@ -58,53 +80,39 @@ if (CONVERT_EXECUTABLE AND NOT WIN32)
DEPENDS ${icon_svg} VERBATIM) DEPENDS ${icon_svg} VERBATIM)
set_source_files_properties (${icon_symbolic} set_source_files_properties (${icon_symbolic}
PROPERTIES SYMBOLIC TRUE) PROPERTIES SYMBOLIC TRUE)
endforeach () endforeach (icon_size)
# Symbolic targets prevent the icons from being either cleaned, set (icon_ico ${CMAKE_CURRENT_SOURCE_DIR}/share/logdiag.ico)
# or pointlessly regenerated slightly differently add_custom_target (logdiag_icons DEPENDS ${icon_symbolic_list}
set (icon_ico ${PROJECT_SOURCE_DIR}/share/logdiag.ico)
add_custom_target (${PROJECT_NAME}_icons
DEPENDS ${icon_symbolic_list}
COMMAND ${CONVERT_EXECUTABLE} ${icon_png_list} ${icon_ico} COMMAND ${CONVERT_EXECUTABLE} ${icon_png_list} ${icon_ico}
COMMENT "Generating logdiag.ico" VERBATIM) COMMENT "Generating logdiag.ico" VERBATIM)
endif () endif (CONVERT_EXECUTABLE AND NOT WIN32)
# Dependencies # Dependencies
find_package (PkgConfig REQUIRED) find_package (GTK2 2.12 REQUIRED gtk)
pkg_check_modules (GTK3 REQUIRED gtk+-3.0 json-glib-1.0) find_package (Lua51 REQUIRED)
link_directories (${GTK3_LIBRARY_DIRS}) find_package (JsonGlib REQUIRED)
if (NOT WIN32)
pkg_search_module (Lua REQUIRED lua>=5.2
lua5.4 lua-5.4 lua5.3 lua-5.3 lua5.2 lua-5.2)
link_directories (${Lua_LIBRARY_DIRS})
else ()
# For whatever reason this now seems to be required
set (LUA_INCLUDE_DIR "${WIN32_DEPENDS_PATH}/include")
find_package (Lua REQUIRED)
if (LUA_VERSION_STRING VERSION_LESS "5.2")
message (FATAL_ERROR "Lua 5.2 not found")
endif ()
set (Lua_LIBRARIES ${LUA_LIBRARIES})
set (Lua_INCLUDE_DIRS ${LUA_INCLUDE_DIR})
endif ()
# Localization # Localization
find_package (Gettext REQUIRED) find_package (Gettext REQUIRED)
file (GLOB project_PO_FILES ${PROJECT_SOURCE_DIR}/po/*.po) file (GLOB project_PO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po)
GETTEXT_CREATE_TRANSLATIONS ( GETTEXT_CREATE_TRANSLATIONS (
${PROJECT_SOURCE_DIR}/po/${PROJECT_NAME}.pot ${CMAKE_CURRENT_SOURCE_DIR}/po/${CMAKE_PROJECT_NAME}.pot
ALL ${project_PO_FILES}) ALL ${project_PO_FILES})
foreach (file ${project_PO_FILES}) foreach (file ${project_PO_FILES})
get_filename_component (translation "${file}" NAME_WE) get_filename_component (translation "${file}" NAME_WE)
list (APPEND project_TRANSLATIONS "${translation}") list (APPEND project_TRANSLATIONS "${translation}")
endforeach () endforeach (file)
# Documentation
# TODO: Add pregenerated docs to the tree
find_package (GtkDoc)
set (project_DOC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/docs/reference")
# Project source files # Project source files
set (liblogdiag_SOURCES set (liblogdiag_SOURCES
${PROJECT_BINARY_DIR}/ld-marshal.c liblogdiag/ld-marshal.c
liblogdiag/ld-types.c liblogdiag/ld-types.c
liblogdiag/ld-undo-action.c liblogdiag/ld-undo-action.c
liblogdiag/ld-diagram.c liblogdiag/ld-diagram.c
@ -113,17 +121,15 @@ set (liblogdiag_SOURCES
liblogdiag/ld-diagram-connection.c liblogdiag/ld-diagram-connection.c
liblogdiag/ld-diagram-view.c liblogdiag/ld-diagram-view.c
liblogdiag/ld-library.c liblogdiag/ld-library.c
liblogdiag/ld-category-view.c liblogdiag/ld-library-toolbar.c
liblogdiag/ld-category-tree-view.c liblogdiag/ld-symbol-category.c
liblogdiag/ld-category-symbol-view.c
liblogdiag/ld-category.c
liblogdiag/ld-symbol.c liblogdiag/ld-symbol.c
liblogdiag/ld-lua.c liblogdiag/ld-lua.c
liblogdiag/ld-lua-symbol.c) liblogdiag/ld-lua-symbol.c)
set (liblogdiag_HEADERS set (liblogdiag_HEADERS
${PROJECT_BINARY_DIR}/ld-marshal.h ${CMAKE_CURRENT_BINARY_DIR}/config.h
${PROJECT_BINARY_DIR}/config.h
liblogdiag/liblogdiag.h liblogdiag/liblogdiag.h
liblogdiag/ld-marshal.h
liblogdiag/ld-types.h liblogdiag/ld-types.h
liblogdiag/ld-undo-action.h liblogdiag/ld-undo-action.h
liblogdiag/ld-diagram.h liblogdiag/ld-diagram.h
@ -132,10 +138,8 @@ set (liblogdiag_HEADERS
liblogdiag/ld-diagram-connection.h liblogdiag/ld-diagram-connection.h
liblogdiag/ld-diagram-view.h liblogdiag/ld-diagram-view.h
liblogdiag/ld-library.h liblogdiag/ld-library.h
liblogdiag/ld-category-view.h liblogdiag/ld-library-toolbar.h
liblogdiag/ld-category-tree-view.h liblogdiag/ld-symbol-category.h
liblogdiag/ld-category-symbol-view.h
liblogdiag/ld-category.h
liblogdiag/ld-symbol.h liblogdiag/ld-symbol.h
liblogdiag/ld-lua.h liblogdiag/ld-lua.h
liblogdiag/ld-lua-private.h liblogdiag/ld-lua-private.h
@ -147,93 +151,79 @@ set (logdiag_TESTS
diagram) diagram)
set (logdiag_SOURCES set (logdiag_SOURCES
${PROJECT_BINARY_DIR}/gresource.c
src/ld-window-main.c src/ld-window-main.c
src/logdiag.c) src/logdiag.c)
set (logdiag_HEADERS set (logdiag_HEADERS
${liblogdiag_HEADERS} ${liblogdiag_HEADERS}
src/ld-window-main.h) src/ld-window-main.h)
# Resource compilation for Windows # Resource compilation for MinGW
if (MINGW)
set (CMAKE_RC_COMPILER_INIT windres)
enable_language (RC)
set (CMAKE_RC_FLAGS "-O coff")
set (CMAKE_RC_COMPILE_OBJECT
"<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> <SOURCE>")
endif (MINGW)
if (WIN32) if (WIN32)
# The file isn't scanned for dependencies, but they will only rarely change set (logdiag_SOURCES
list (APPEND logdiag_SOURCES share/logdiag.rc) ${logdiag_SOURCES}
endif () share/logdiag.rc)
endif (WIN32)
# Generate a configure file
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories (${CMAKE_CURRENT_BINARY_DIR})
# Generate marshallers # Generate marshallers
function (glib_genmarshal listfile prefix) find_program (GLIB_GENMARSHAL_EXECUTABLE glib-genmarshal)
find_program (GLIB_GENMARSHAL_EXECUTABLE glib-genmarshal) if (NOT GLIB_GENMARSHAL_EXECUTABLE)
if (NOT GLIB_GENMARSHAL_EXECUTABLE)
message (FATAL_ERROR "glib-genmarshal not found") message (FATAL_ERROR "glib-genmarshal not found")
endif () endif (NOT GLIB_GENMARSHAL_EXECUTABLE)
get_filename_component (_basename "${listfile}" NAME_WE) function (glib_genmarshal base prefix)
set (_command_base ${GLIB_GENMARSHAL_EXECUTABLE} --prefix ${prefix} get_filename_component (base_path "${base}" PATH)
"${listfile}") get_filename_component (base_name "${base}" NAME)
set (command_base ${GLIB_GENMARSHAL_EXECUTABLE}
--prefix ${prefix} "${base_name}.list")
add_custom_command (OUTPUT ${_basename}.c ${_basename}.h # On Windows, the final makefile may contain:
COMMAND ${_command_base} --body > ${_basename}.c
COMMAND ${_command_base} --header > ${_basename}.h
DEPENDS "${listfile}"
COMMENT "Generating marshallers source files" VERBATIM)
endfunction ()
glib_genmarshal (${PROJECT_SOURCE_DIR}/liblogdiag/ld-marshal.list ld_marshal)
# Generate resources
function (glib_compile_resources xml target)
find_program (GLIB_COMPILE_RESOURCES_EXECUTABLE glib-compile-resources)
if (NOT GLIB_COMPILE_RESOURCES_EXECUTABLE)
message (FATAL_ERROR "glib-compile-resources not found")
endif ()
# glib-compile-resources reads paths relative to its working directory
get_filename_component (_xml_path "${xml}" PATH)
# On Windows, the final Makefile may contain:
# cd e:\abc && ... # cd e:\abc && ...
# That won't actually change the directory. We have to do: # That won't actually change the directory. We have to do:
# cd e:\abc && e: && ... # cd e:\abc && e: && ...
set (_prefix) if (WIN32 AND "${base_path}" MATCHES "^.:[/\\\\]")
if (WIN32 AND "${_xml_path}" MATCHES "^.:[/\\\\]") string (SUBSTRING "${base_path}" 0 2 base_drive)
string (SUBSTRING "${_xml_path}" 0 2 _xml_drive) set (command_base "${base_drive}" && "${command_base}")
set (_prefix ${_xml_drive} &&) endif (WIN32 AND "${base_path}" MATCHES "^.:[/\\\\]")
endif ()
# VERBATIM would cause problems, so it is not used here # NOTE: VERBATIM would cause problems, so it is not used here
add_custom_command (OUTPUT ${target} add_custom_command (OUTPUT ${base}.c
COMMAND ${_prefix} ${GLIB_COMPILE_RESOURCES_EXECUTABLE} COMMAND ${command_base} --body > "${base_name}.c"
--generate-source --target ${target} "${xml}" DEPENDS "${xml}" DEPENDS "${base}.list"
WORKING_DIRECTORY "${_xml_path}" COMMENT "Compiling resources") WORKING_DIRECTORY "${base_path}"
COMMENT "Generating marshallers source file")
add_custom_command (OUTPUT ${base}.h
COMMAND ${command_base} --header > "${base_name}.h"
DEPENDS "${base}.list"
WORKING_DIRECTORY "${base_path}"
COMMENT "Generating marshallers header file")
endfunction (glib_genmarshal)
execute_process (COMMAND ${GLIB_COMPILE_RESOURCES_EXECUTABLE} glib_genmarshal (${CMAKE_CURRENT_SOURCE_DIR}/liblogdiag/ld-marshal
--generate-dependencies "${xml}" ld_marshal)
WORKING_DIRECTORY "${_xml_path}" OUTPUT_VARIABLE _deps)
string (REPLACE "\n" ";" _deps "${_deps}")
foreach (_dep ${_deps})
set_property (SOURCE "${target}"
APPEND PROPERTY OBJECT_DEPENDS "${_xml_path}/${_dep}")
endforeach ()
configure_file ("${xml}" glib-compile-resources.stamp COPYONLY) include_directories (${CMAKE_CURRENT_SOURCE_DIR})
endfunction () include_directories (${GTK2_INCLUDE_DIRS}
${JSON_GLIB_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
glib_compile_resources (${PROJECT_SOURCE_DIR}/share/logdiag.gresource.xml set (logdiag_LIBS ${GTK2_LIBRARIES}
${PROJECT_BINARY_DIR}/gresource.c) ${JSON_GLIB_LIBRARIES} ${LUA_LIBRARIES})
# Generate a configure file
add_definitions (-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36)
add_definitions (-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36)
configure_file (config.h.in ${PROJECT_BINARY_DIR}/config.h)
include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR}
${GTK3_INCLUDE_DIRS} ${Lua_INCLUDE_DIRS})
set (logdiag_LIBS ${GTK3_LIBRARIES} ${Lua_LIBRARIES} m)
if (WIN32) if (WIN32)
find_package (Intl REQUIRED) find_package (LibIntl REQUIRED)
list (APPEND logdiag_LIBS ${Intl_LIBRARIES} shell32) list (APPEND logdiag_LIBS ${LIBINTL_LIBRARIES})
endif () endif (WIN32)
# Build the library # Build the library
add_library (liblogdiag STATIC ${liblogdiag_SOURCES} ${liblogdiag_HEADERS}) add_library (liblogdiag STATIC ${liblogdiag_SOURCES} ${liblogdiag_HEADERS})
@ -243,132 +233,51 @@ set_target_properties (liblogdiag PROPERTIES OUTPUT_NAME logdiag)
add_executable (logdiag WIN32 ${logdiag_SOURCES} ${logdiag_HEADERS}) add_executable (logdiag WIN32 ${logdiag_SOURCES} ${logdiag_HEADERS})
target_link_libraries (logdiag liblogdiag ${logdiag_LIBS}) target_link_libraries (logdiag liblogdiag ${logdiag_LIBS})
# GSettings
find_program (GLIB_COMPILE_SCHEMAS_EXECUTABLE glib-compile-schemas)
if (NOT GLIB_COMPILE_SCHEMAS_EXECUTABLE)
message (FATAL_ERROR "glib-compile-schemas not found")
endif ()
set (GSETTINGS_DIR "${PROJECT_SOURCE_DIR}/share")
set (GSETTINGS_SCHEMAS "${GSETTINGS_DIR}/${PROJECT_NAME}.gschema.xml")
if (OPTION_NOINSTALL)
set (GSETTINGS_COMPILED_SCHEMA "${PROJECT_BINARY_DIR}/gschemas.compiled")
add_custom_command (OUTPUT "${GSETTINGS_COMPILED_SCHEMA}"
COMMAND ${GLIB_COMPILE_SCHEMAS_EXECUTABLE}
"--targetdir=${PROJECT_BINARY_DIR}" "${GSETTINGS_DIR}"
DEPENDS "${GSETTINGS_SCHEMAS}"
COMMENT "Compiling GSettings schema files" VERBATIM)
add_custom_target (${PROJECT_NAME}-gschema ALL
DEPENDS "${GSETTINGS_COMPILED_SCHEMA}")
endif ()
# Testing # Testing
option (BUILD_TESTING "Build tests" OFF)
if (BUILD_TESTING) if (BUILD_TESTING)
enable_testing () enable_testing ()
add_test (NAME test-gschema-${PROJECT_NAME}
COMMAND ${GLIB_COMPILE_SCHEMAS_EXECUTABLE} --dry-run "${GSETTINGS_DIR}")
foreach (name ${logdiag_TESTS}) foreach (name ${logdiag_TESTS})
add_executable (test-${name} tests/${name}.c) add_executable (test-${name} tests/${name}.c)
target_link_libraries (test-${name} liblogdiag ${logdiag_LIBS}) target_link_libraries (test-${name} liblogdiag ${logdiag_LIBS})
add_test (NAME test-${name} COMMAND test-${name})
list (APPEND logdiag_TEST_TARGETS test-${name}) add_test (test-${name} test-${name})
endforeach () endforeach (name)
if (WIN32 AND NOT CMAKE_CROSSCOMPILING) endif (BUILD_TESTING)
set_tests_properties (${logdiag_TEST_TARGETS}
PROPERTIES ENVIRONMENT "PATH=${WIN32_DEPENDS_PATH}/bin")
endif ()
endif ()
# Generate documentation # Generate documentation
if (OPTION_GTKDOC) if (GTK_DOC_FOUND)
find_package (GtkDoc 1.25 REQUIRED) GTK_DOC_RUN (WORKING_DIR ${project_DOC_DIR}
set (project_DOC_DIR "${PROJECT_BINARY_DIR}/liblogdiag") SOURCE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/liblogdiag
SCANGOBJ liblogdiag ${logdiag_LIBS}
# Extracted LDFLAGS didn't contain -l in CMake 3.21.3 and gtk-doc 1.33.2, XML ${project_DOC_DIR}/xml --sgml-mode
# pass them explicitly and work around insanity; CMake still exits with HTML ${project_DOC_DIR}/html)
# an error and gtk-doc produces empty HTML documentation endif (GTK_DOC_FOUND)
string (REGEX REPLACE "(;)([^-])" "\\1-l\\2" xldflags "${logdiag_LIBS}")
set_target_properties (liblogdiag PROPERTIES LINK_LIBRARIES "")
# The "official" module wants an XML file I don't want to give it
file (WRITE ${PROJECT_BINARY_DIR}/liblogdiag-docs-dummy.xml "<book/>")
# XXX: not our bug but xml/gtkdocentities.ent cannot be passed
# XXX: this causes `make clean` to remove the entire build directory,
# because it marks CMAKE_CURRENT_BINARY_DIR as an output
gtk_doc_add_module (liblogdiag
SOURCE ${PROJECT_SOURCE_DIR}/liblogdiag
SUFFIXES c h LDFLAGS "-l${xldflags}"
XML ${PROJECT_BINARY_DIR}/liblogdiag-docs-dummy.xml
LIBRARIES liblogdiag)
endif ()
find_package (CppCheck)
GENERATE_CPPCHECK (SOURCES liblogdiag src tests ENABLE_IDS all
TARGET_NAME ${PROJECT_NAME}_cppcheck INCLUDES ${PROJECT_BINARY_DIR})
# Various clang-based diagnostics, loads of fake positives and spam
if (OPTION_CLANG_TIDY)
set (clang_tidy_checks
clang-analyzer-* bugprone-* misc-* readability-* performance-*
-bugprone-reserved-identifier # GObject
-performance-no-int-to-ptr # GObject
-bugprone-narrowing-conversions
-bugprone-macro-parentheses # too coarse-grained
-readability-braces-around-statements # fine by me
-readability-isolate-declaration # fine by me
-readability-magic-numbers # too coarse-grained
-misc-unused-parameters) # fine by me
string (REPLACE ";" "," clang_tidy_checks "${clang_tidy_checks}")
set (clang_tidy_config "{
Checks: '${clang_tidy_checks}',
CheckOptions: [{
key: readability-function-cognitive-complexity.Threshold,
value: '30'
}]}")
string (REPLACE "\n" " " clang_tidy_config "${clang_tidy_config}")
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
set (clang_tidy_sources ${liblogdiag_SOURCES} ${logdiag_SOURCES})
add_custom_target (${PROJECT_NAME}_clang_tidy
COMMAND clang-tidy --quiet -p ${PROJECT_BINARY_DIR}
"--config=${clang_tidy_config}" ${clang_tidy_sources}
| sh -c "cat 1>&2"
DEPENDS ${clang_tidy_sources} VERBATIM
USES_TERMINAL WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif ()
# Installation # Installation
install (DIRECTORY share/gui share/library
DESTINATION share/${CMAKE_PROJECT_NAME})
if (WIN32) if (WIN32)
install (TARGETS logdiag DESTINATION .) install (TARGETS logdiag DESTINATION .)
install (DIRECTORY install (DIRECTORY
${WIN32_DEPENDS_PATH}/bin/ ${WIN32_DEPENDS_PATH}/bin/
DESTINATION . DESTINATION .
FILES_MATCHING PATTERN "*.dll" PATTERN "gspawn-*-helper.exe") FILES_MATCHING PATTERN "*.dll"
PATTERN "libgettext*" EXCLUDE)
install (DIRECTORY install (DIRECTORY
${WIN32_DEPENDS_PATH}/etc/ ${WIN32_DEPENDS_PATH}/etc/
DESTINATION etc) DESTINATION etc)
install (DIRECTORY install (DIRECTORY
${WIN32_DEPENDS_PATH}/lib/glib-2.0
${WIN32_DEPENDS_PATH}/lib/gtk-2.0
${WIN32_DEPENDS_PATH}/lib/gdk-pixbuf-2.0 ${WIN32_DEPENDS_PATH}/lib/gdk-pixbuf-2.0
DESTINATION lib DESTINATION lib)
FILES_MATCHING PATTERN "*" PATTERN "*.a" EXCLUDE)
install (DIRECTORY install (DIRECTORY
${WIN32_DEPENDS_PATH}/share/glib-2.0/schemas ${WIN32_DEPENDS_PATH}/share/themes/MS-Windows
DESTINATION share/glib-2.0 DESTINATION share/themes)
FILES_MATCHING PATTERN "org.gtk.Settings.*")
install (DIRECTORY
${WIN32_DEPENDS_PATH}/share/icons/Adwaita
DESTINATION share/icons OPTIONAL)
install (FILES
${WIN32_DEPENDS_PATH}/share/icons/hicolor/index.theme
DESTINATION share/icons/hicolor)
install (DIRECTORY share/icons DESTINATION share)
# Avoid partial translations # Avoid partial translations
file (GLOB locales ${WIN32_DEPENDS_PATH}/share/locale/*) file (GLOB locales ${WIN32_DEPENDS_PATH}/share/locale/*)
@ -379,84 +288,74 @@ if (WIN32)
install (DIRECTORY install (DIRECTORY
${WIN32_DEPENDS_PATH}/share/locale/${translation} ${WIN32_DEPENDS_PATH}/share/locale/${translation}
DESTINATION share/locale) DESTINATION share/locale)
endif () endif (translation_found GREATER -1)
endforeach () endforeach (locale)
else (WIN32)
install (SCRIPT Win32Cleanup.cmake)
else ()
install (TARGETS logdiag DESTINATION bin) install (TARGETS logdiag DESTINATION bin)
install (FILES share/logdiag.desktop DESTINATION share/applications) install (FILES share/logdiag.desktop DESTINATION share/applications)
install (FILES share/logdiag.xml DESTINATION share/mime/packages) install (FILES share/logdiag.xml DESTINATION share/mime/packages)
install (DIRECTORY share/icons DESTINATION share) install (DIRECTORY share/icons DESTINATION share)
# Don't install the documentation yet as we don't install any library # Don't install the documentation yet as we don't install any library
# install (DIRECTORY "${project_DOC_DIR}/html/" # install (DIRECTORY "${project_DOC_DIR}/html/"
# DESTINATION share/gtk-doc/html/${PROJECT_NAME}) # DESTINATION share/gtk-doc/html/${CMAKE_PROJECT_NAME})
install (FILES LICENSE NEWS DESTINATION share/doc/${PROJECT_NAME}) install (FILES LICENSE NEWS DESTINATION share/doc/${CMAKE_PROJECT_NAME})
endif () endif (WIN32)
install (DIRECTORY docs/user-guide DESTINATION share/doc/${PROJECT_NAME})
install (DIRECTORY share/library DESTINATION share/${PROJECT_NAME})
install (FILES ${GSETTINGS_SCHEMAS} DESTINATION share/glib-2.0/schemas
RENAME "${project_ID}.gschema.xml")
install (CODE " # DESTDIR is not in use on Windows (WIN32 is only native here!)
if (WIN32 OR \"\$ENV{DESTDIR}\" STREQUAL \"\")
execute_process (COMMAND \"${GLIB_COMPILE_SCHEMAS_EXECUTABLE}\"
\"\${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas\")
endif ()")
# CPack # CPack
set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch") set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Schematic editor")
set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>") set (CPACK_PACKAGE_VENDOR "Premysl Janouch")
set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") set (CPACK_PACKAGE_CONTACT "p.janouch@gmail.com")
set (CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set (CPACK_PACKAGE_VERSION_MAJOR ${project_VERSION_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${project_VERSION_MINOR})
set (CPACK_PACKAGE_VERSION_PATCH ${project_VERSION_PATCH})
if (WIN32) if (WIN32)
set (CPACK_GENERATOR "NSIS;ZIP") set (CPACK_GENERATOR "NSIS;ZIP")
else () else (WIN32)
set (CPACK_GENERATOR "TGZ;ZIP") set (CPACK_GENERATOR "TGZ;ZIP")
set (CPACK_SET_DESTDIR TRUE) endif (WIN32)
endif ()
set (CPACK_PACKAGE_FILE_NAME set (CPACK_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") "${CMAKE_PROJECT_NAME}-${project_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME} ${CPACK_PACKAGE_VERSION}") set (CPACK_PACKAGE_INSTALL_DIRECTORY
"${CMAKE_PROJECT_NAME} ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
# XXX: It is still possible to install multiple copies, making commands collide. # FIXME: It is possible to install multiple copies. Everything screws up then.
set (CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) set (CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/share\\\\header.bmp")
set (CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${PROJECT_NAME}")
set (CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/share\\\\header.bmp")
set (CPACK_NSIS_INSTALLED_ICON_NAME "logdiag.exe") set (CPACK_NSIS_INSTALLED_ICON_NAME "logdiag.exe")
set (CPACK_NSIS_URL_INFO_ABOUT "${project_URL}") set (CPACK_NSIS_CREATE_ICONS_EXTRA "
set (CPACK_NSIS_HELP_LINK "${project_URL}") CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\logdiag.lnk' '\$INSTDIR\\\\logdiag.exe'")
# Or CPACK_NSIS_EXECUTABLES_DIRECTORY needs to be changed from "bin" set (CPACK_NSIS_DELETE_ICONS_EXTRA "
set (CPACK_NSIS_MENU_LINKS "logdiag.exe" ${PROJECT_NAME}) Delete '\$SMPROGRAMS\\\\$MUI_TEMP\\\\logdiag.lnk'")
set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS [[ set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
WriteRegStr HKCR '.ldd' '' 'logdiag.Diagram' WriteRegStr HKCR '.ldd' '' 'logdiag.Diagram'
WriteRegStr HKCR 'logdiag.Diagram' '' 'logdiag Diagram' WriteRegStr HKCR 'logdiag.Diagram' '' 'logdiag Diagram'
WriteRegStr HKCR 'logdiag.Diagram\\shell\\open\\command' '' '\"$INSTDIR\\logdiag.exe\" \"%1\"' WriteRegStr HKCR 'logdiag.Diagram\\\\shell\\\\open\\\\command' '' '\\\"\$INSTDIR\\\\logdiag.exe\\\" \\\"%1\\\"'
WriteRegStr HKCR 'logdiag.Diagram\\shell\\edit\\command' '' '\"$INSTDIR\\logdiag.exe\" \"%1\"' WriteRegStr HKCR 'logdiag.Diagram\\\\shell\\\\edit\\\\command' '' '\\\"\$INSTDIR\\\\logdiag.exe\\\" \\\"%1\\\"'
System::Call 'shell32::SHChangeNotify(i,i,i,i) (0x08000000, 0x1000, 0, 0)' System::Call 'shell32::SHChangeNotify(i,i,i,i) (0x08000000, 0x1000, 0, 0)'")
]]) set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS [[
DeleteRegKey HKCR 'logdiag.Diagram' DeleteRegKey HKCR 'logdiag.Diagram'
System::Call 'shell32::SHChangeNotify(i,i,i,i) (0x08000000, 0x1000, 0, 0)' System::Call 'shell32::SHChangeNotify(i,i,i,i) (0x08000000, 0x1000, 0, 0)'")
]])
string (REPLACE "http://" "http:\\\\\\\\" project_URL_NSIS "${project_URL}")
set (CPACK_NSIS_URL_INFO_ABOUT "${project_URL_NSIS}")
set (CPACK_DEBIAN_PACKAGE_DEPENDS set (CPACK_DEBIAN_PACKAGE_DEPENDS
"libgtk3.0-0 (>= 3.8), libjson-glib-1.0-0 (>= 0.10.4), liblua5.2-0") "libgtk2.0-0 (>= 2.12), libjson-glib-1.0-0 (>= 0.10.4), liblua5.1-0, librsvg2-common")
set (CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS set (CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS
"libgtk3.0-dev (>= 3.8), libjson-glib-dev (>= 0.10.4), liblua5.2-0-dev") "libgtk2.0-dev (>= 2.12), libjson-glib-dev (>= 0.10.4), liblua5.1-0-dev")
set (CPACK_DEBIAN_PACKAGE_SECTION "Electronics") set (CPACK_DEBIAN_PACKAGE_SECTION "Electronics")
set (CPACK_DEBIAN_PACKAGE_HOMEPAGE "${project_URL}") set (CPACK_DEBIAN_PACKAGE_HOMEPAGE "${project_URL}")
set (CPACK_RPM_PACKAGE_REQUIRES "gtk3 >= 3.8, json-glib >= 0.10.4, lua = 5.2") set (CPACK_RPM_PACKAGE_REQUIRES "gtk2 >= 2.12, json-glib >= 0.10.4, lua = 5.1, librsvg2")
set (CPACK_RPM_PACKAGE_GROUP "Graphics") set (CPACK_RPM_PACKAGE_GROUP "Graphics")
set (CPACK_RPM_PACKAGE_LICENSE "0BSD") set (CPACK_RPM_PACKAGE_LICENSE "BSD")
set (CPACK_RPM_PACKAGE_URL "${project_URL}") set (CPACK_RPM_PACKAGE_URL "${project_URL}")
set (CPACK_SOURCE_GENERATOR "TGZ;ZIP") set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user;/win32-depends") set (CPACK_SOURCE_IGNORE_FILES "/.git;/build;/win32-depends;/liblogdiag/ld-marshal.[ch]")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}") set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${project_VERSION}")
include (CPack) include (CPack)

34
LICENSE
View File

@ -1,12 +1,26 @@
Copyright (c) 2010 - 2021, Přemysl Eric Janouch <p@janouch.name> Copyright Premysl Janouch 2010 - 2011
All rights reserved.
Permission to use, copy, modify, and/or distribute this software for any Redistribution and use in source and binary forms, with or without
purpose with or without fee is hereby granted. modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* The names of the copyright holders and contributors may not be used
to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

41
NEWS
View File

@ -1,44 +1,3 @@
Version 0.3.0
- Added basic print functionality (lines may have the wrong width).
- Fine-tuned rendering of a few symbols.
- Bound toggling of the grid to the # key, following Inkscape.
- Ensured all opened files are added to the list of recent files.
- View position is reset when opening files.
- Made the user guide available from the Help menu.
- The website link in the About dialog now opens on Windows XP.
- Put the project's license in the About dialog.
- Made Windows builds considerably slimmer.
Version 0.2.1
- Set up grounds for 64-bit Windows builds using the latest GTK+ 3.
- Made the Windows installer ask to uninstall previous versions first.
- Worked around a mysterious recent GTK+ bug with symbol dragging.
- Put a default filename in the save dialog, ensuring a file extension.
Version 0.2.0
- Added a library pane instead of a toolbar.
- Added scrolling using the middle mouse button.
- View menu settings are remembered.
- Fixed command line parsing on Windows;
it's not limited to the system ANSI codepage anymore.
- Fixed checking for the Shift key when selecting.
- Terminals are ignored when hovering the cursor above a selection.
- Disallowed wheel zooming when holding mouse buttons.
- Fixed the behaviour of saving.
- Fixed rapid right-clicking rotating more than it should.
- Symbol categories are also loaded from user-specific directories.
- Show current zoom in the statusbar.
- Ported to GTK+ 3 and Lua 5.2.
- Various unimportant fixes and changes.
- Known issues: Windows XP looks ugly with the classic theme, little we can do.
Version 0.1.2
- Updated symbol library.
- Added Slovak, Polish and German translations.
- Rotation of symbols is also allowed while placing them.
- Now gluing to terminal points when creating connections.
- Toolbars and the grid can be hidden.
Version 0.1.1 Version 0.1.1
- Rotation of symbols made possible. - Rotation of symbols made possible.
- Connections can also be created at ends of other connections. - Connections can also be created at ends of other connections.

View File

@ -1,127 +0,0 @@
logdiag
=======
'logdiag' is a simple multiplatform schematic editor written in GTK+.
This software has never really been finished, and is no longer being worked on,
although I strive to keep it building on Windows XP and elsewhere.
image::docs/user-guide/logdiag-en.png[align="center"]
Packages
--------
Regular releases are sporadic. git master should be stable enough.
You can get a package with the latest development version using Arch Linux's
https://aur.archlinux.org/packages/logdiag-git[AUR],
or as a https://git.janouch.name/p/nixexprs[Nix derivation].
Windows installers can be downloaded from
https://git.janouch.name/p/logdiag/releases[the Releases page on Gitea].
Requirements
------------
Runtime dependencies: GTK+ >= 3.8, json-glib >= 0.10.4, lua >= 5.2 +
Build dependencies: CMake >= 3.10
Build from source on Unix-like systems
--------------------------------------
First check that you have all the required dependencies installed, including
development packages, if your distribution provides them.
Reserve a directory for an out-of-source build:
$ mkdir build
$ cd build
Let CMake prepare the build. You may change the directory where you want the
application to be installed. The default is _/usr/local_.
$ cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
Now you have two basic choices of installing the application:
1. Using _make install_:
+
# make install
2. Using _cpack_:
+
You have to choose a package format understood by your system package manager.
CMake offers DEB and RPM.
+
After _cpack_ finishes making the package, install this file.
+
$ cpack -G DEB
# dpkg -i logdiag-version-system-arch.deb
Build from source on Windows
----------------------------
_Note that using the current method we're stuck with GTK+ 3.8.2, which works
worse on Windows 10, but better on XP and under WINE._
First, install CMake and MinGW (mingw32-base-bin, mingw32-gettext-dev).
Ensure they're both in your system path. If you want to build an installation
package, also install NSIS. If you want to build within a path containing
spaces, https://gitlab.kitware.com/cmake/cmake/-/issues/22396[fix] your CMake's
FindPkgConfig.cmake module to say:
separate_arguments(_pkgconfig_invoke_result UNIX_COMMAND "${_pkgconfig_invoke_result}")
Run the following command in the directory with source files to automatically
fetch and set up all dependencies:
> cmake -P Win32Depends.cmake
Note that on Windows XP, CMake will fail to download those files, even with
https://emailarchitect.net/easendmail/sdk/html/object_tls12.htm[updates].
You will have to run the script externally.
Reserve a directory for an out-of-source build and let CMake prepare the build:
> mkdir build
> cd build
> cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
Now you can generate a package with CPack. You may choose between:
1. An NSIS-based installation package:
+
> cpack -G NSIS
2. A portable ZIP package:
+
> cpack -G ZIP
By default, that is if you specify no generator, both packages are built.
Cross-compilation for Windows
-----------------------------
The procedure is almost exactly the same as before, including the requirements.
Just install MinGW-w64 and let automation take care of the rest.
$ cmake -P Win32Depends.cmake
$ mkdir build
$ cd build
$ cmake -DCMAKE_TOOLCHAIN_FILE=../ToolchainCrossMinGWW64.cmake \
-DCMAKE_BUILD_TYPE=Release ..
$ cpack
Alternatively, for an unnecessarily bloated MSYS2-based 64-bit build:
$ sh -e Win64Depends.sh
$ cmake -DCMAKE_TOOLCHAIN_FILE=ToolchainCrossWin64.cmake \
-DCMAKE_BUILD_TYPE=Release -B build
$ cmake --build build -- package
Contributing and Support
------------------------
Use https://git.janouch.name/p/logdiag to report any bugs, request features,
or submit pull requests. `git send-email` is tolerated. If you want to discuss
the project, feel free to join me at ircs://irc.janouch.name, channel #dev.
Bitcoin donations are accepted at: 12r5uEWEgcHC46xd64tt3hHt9EUvYYDHe9
License
-------
This software is released under the terms of the 0BSD license, the text of which
is included within the package along with the list of authors.

71
README.md Normal file
View File

@ -0,0 +1,71 @@
# logdiag
logdiag is a schematic editor written in GTK+.
__This software is considered to be alpha quality and cannot be recommended
for regular usage.__
## Requirements
Runtime dependencies:
- GTK+ &gt;= 2.12
- json-glib &gt;= 0.10.4
- lua = 5.1
- librsvg &gt;= 2.0
Build dependencies:
- CMake &gt;= 2.6
## Installation from sources on Unix-like systems
First check that you have all the required dependencies installed, including
all development packages, if your distribution provides them.
Reserve a directory for an out-of-source build:
$ mkdir build
$ cd build
Let CMake prepare the build. You may change the directory where you want
the application to be installed. The default is _/usr/local_.
$ cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
Now you have two basic choices of installing the application:
1. Using _make install_:
# make install
2. Using _cpack_; you have to choose a package format understood by your
system package manager. CMake offers DEB and RPM.
After _cpack_ finishes making the package, install this file.
$ cpack -G DEB
# dpkg -i logdiag-0.0-Linux-x86_64.deb
# Building from sources on Windows
First install CMake 2.8 and MinGW. Add both to the system path.
If you want to build an installation package, also install NSIS.
Run the following command in the directory with source files
to automatically fetch and setup all dependencies:
> cmake -P Win32Depends.cmake
Reserve a directory for an out-of-source build:
> mkdir build
> cd build
Let CMake prepare the build:
> cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
Now you can generate a package with CPack. You may choose between:
1. An NSIS-based installation package:
> cpack -G NSIS
2. A portable ZIP package:
> cpack -G ZIP
By default, that is if you specify no generator, both packages are built.

View File

@ -1,15 +0,0 @@
set (CMAKE_SYSTEM_NAME "Windows")
set (CMAKE_SYSTEM_PROCESSOR "x86")
set (CMAKE_C_COMPILER "i586-mingw32msvc-gcc")
set (CMAKE_CXX_COMPILER "i586-mingw32msvc-g++")
set (CMAKE_RC_COMPILER "i586-mingw32msvc-windres")
# Remember to set WINEPATH for library dependencies
set (CMAKE_CROSSCOMPILING_EMULATOR "wine")
set (CMAKE_FIND_ROOT_PATH "/usr/i586-mingw32msvc")
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@ -1,15 +0,0 @@
set (CMAKE_SYSTEM_NAME "Windows")
set (CMAKE_SYSTEM_PROCESSOR "x86")
set (CMAKE_C_COMPILER "i686-w64-mingw32-gcc")
set (CMAKE_CXX_COMPILER "i686-w64-mingw32-g++")
set (CMAKE_RC_COMPILER "i686-w64-mingw32-windres")
# Remember to set WINEPATH for library dependencies
set (CMAKE_CROSSCOMPILING_EMULATOR "wine")
set (CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32")
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@ -1,15 +0,0 @@
set (CMAKE_SYSTEM_NAME "Windows")
set (CMAKE_SYSTEM_PROCESSOR "x86_64")
set (CMAKE_C_COMPILER "x86_64-w64-mingw32-gcc")
set (CMAKE_CXX_COMPILER "x86_64-w64-mingw32-g++")
set (CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres")
# Remember to set WINEPATH for library dependencies
set (CMAKE_CROSSCOMPILING_EMULATOR "wine64")
set (CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32")
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@ -1,37 +0,0 @@
# To be run from cmake_install.cmake, eradicates all unreferenced libraries.
# CMake 3.9.6 has a parsing bug with ENCODING UTF-8.
cmake_minimum_required (VERSION 3.10)
# CPack runs this almost without any CMake variables at all
# (cmStateSnapshot::SetDefaultDefinitions(), CMAKE_INSTALL_PREFIX, [DESTDIR])
set (installdir "${CMAKE_INSTALL_PREFIX}")
if (NOT installdir OR installdir MATCHES "^/usr(/|$)")
return ()
endif ()
# The function is recursive and CMake has tragic scoping behaviour;
# environment variables are truly global there, in the absence of a cache
unset (ENV{seen})
function (expand path)
set (seen $ENV{seen})
if (path IN_LIST seen OR NOT EXISTS "${path}")
return ()
endif ()
set (ENV{seen} "$ENV{seen};${path}")
file (STRINGS "${path}" strings REGEX "[.][Dd][Ll][Ll]$" ENCODING UTF-8)
foreach (string ${strings})
string (REGEX MATCH "[-.+_a-zA-Z0-9]+$" word "${string}")
expand ("${installdir}/${word}")
endforeach ()
endfunction ()
file (GLOB roots LIST_DIRECTORIES false "${installdir}/*.[Ee][Xx][Ee]"
"${installdir}/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.[Dd][Ll][Ll]")
foreach (binary ${roots})
expand ("${binary}")
endforeach ()
file (GLOB libraries LIST_DIRECTORIES false "${installdir}/*.[Dd][Ll][Ll]")
list (REMOVE_ITEM libraries $ENV{seen})
file (REMOVE ${libraries})

View File

@ -1,11 +1,11 @@
# Usage: cmake -P Win32Depends.cmake # Usage: cmake -P Win32Depends.cmake
# Only CMake 3.1+ supports XZ archives, not sure when 7z support comes from
cmake_minimum_required (VERSION 3.9)
# Directories # Directories
set (working_dir ${CMAKE_CURRENT_BINARY_DIR}/win32-depends) set (working_dir ${CMAKE_CURRENT_BINARY_DIR}/win32-depends)
set (pkg_dir ${working_dir}/packages) set (pkg_dir ${working_dir}/packages)
set (bsdtar_dir ${working_dir}/bsdtar)
set (bsdtar_executable ${bsdtar_dir}/bsdtar)
set (tmp_dir ${working_dir}/tmp)
file (MAKE_DIRECTORY ${working_dir}) file (MAKE_DIRECTORY ${working_dir})
file (MAKE_DIRECTORY ${pkg_dir}) file (MAKE_DIRECTORY ${pkg_dir})
@ -15,34 +15,63 @@ file (GLOB files ${working_dir}/*)
list (REMOVE_ITEM files ${pkg_dir}) list (REMOVE_ITEM files ${pkg_dir})
if (files) if (files)
file (REMOVE_RECURSE ${files}) file (REMOVE_RECURSE ${files})
endif () endif (files)
# Packages # Packages
set (pkg_list "geany" "winlibs" "mingw_lua") set (pkg_list "bsdtar" "gtk" "opensuse" "mingw_lua")
# https://sourceforge.net/projects/urlget/files set (pkg_bsdtar_root "http://sourceforge.net/projects/mingw/files/MinGW")
# /GTK%2B%203%20binary%20for%20Windows/GTK%2B%203.16.6/ set (pkg_bsdtar_urls
# contains a binary bundle that may be more or less simply transplanted over, "${pkg_bsdtar_root}/libarchive/libarchive-2.8.3-1/bsdtar-2.8.3-1-mingw32-bin.tar.bz2"
# due to ABI compatibility, however something is wrong with icons, "${pkg_bsdtar_root}/libarchive/libarchive-2.8.3-1/libarchive-2.8.3-1-mingw32-dll-2.tar.bz2"
# and it looks alien on Windows XP (use themes) for close to no improvement. "${pkg_bsdtar_root}/expat/expat-2.0.1-1/libexpat-2.0.1-1-mingw32-dll-1.tar.gz"
set (pkg_geany_root "https://download.geany.org/contrib/gtk") "${pkg_bsdtar_root}/xz/xz-4.999.9beta_20100401-1/liblzma-4.999.9beta_20100401-1-mingw32-dll-1.tar.bz2"
set (pkg_geany_urls "${pkg_geany_root}/gtk+-bundle_3.8.2-20131001_win32.zip") "${pkg_bsdtar_root}/bzip2/release%201.0.5-2/libbz2-1.0.5-2-mingw32-dll-2.tar.gz"
set (pkg_geany_md5 "3f9b159207edf44937f209b4a5e6bb63") "${pkg_bsdtar_root}/zlib/zlib-1.2.3-1-mingw32/libz-1.2.3-1-mingw32-dll-1.tar.gz")
set (pkg_bsdtar_md5
"160168b10075bf11a6405d43d98b1612"
"8409b7e9138423b491a41faff742a362"
"deb721ecbcb723d5d3ac4b7dc0860402"
"5f98e85610656cfcfa68c45e601bad0e"
"86a00cac65439ef3e3cb5c466cf6695f"
"4ccd26ac32ad3ffdef5e78cdc770ef12")
set (pkg_winlibs_root "http://sourceforge.net/projects/winlibs/files") set (pkg_gtk_root "http://ftp.gnome.org/pub/gnome/binaries/win32")
set (pkg_winlibs_urls "${pkg_winlibs_root}/GTK+/libjson-glib-1.0-1-mingw32.7z") set (pkg_gtk_urls
set (pkg_winlibs_md5 "f06e42c5998dae5fb6245fecc96a403e") "${pkg_gtk_root}/gtk+/2.22/gtk+-bundle_2.22.1-20101227_win32.zip"
"${pkg_gtk_root}/librsvg/2.32/librsvg_2.32.1-1_win32.zip"
"${pkg_gtk_root}/librsvg/2.32/librsvg-dev_2.32.1-1_win32.zip"
"${pkg_gtk_root}/librsvg/2.32/svg-gdk-pixbuf-loader_2.32.1-1_win32.zip"
"${pkg_gtk_root}/libcroco/0.6/libcroco_0.6.2-1_win32.zip"
"${pkg_gtk_root}/dependencies/libxml2_2.7.7-1_win32.zip"
"${pkg_gtk_root}/dependencies/libxml2-dev_2.7.7-1_win32.zip"
"${pkg_gtk_root}/dependencies/gettext-tools-0.17.zip")
set (pkg_gtk_md5
"a545c0ca1e6a312701d42a18e49572af"
"2c712a8d7a652363241c0967098515db"
"b09662bc99c5c1b8edb8af32a1722477"
"bf4e34f1f175b88430159d33e01d0c49"
"2d90c71404be0de4e5f3259f63a3e278"
"bd6b3d8c35e06a00937db65887c6e287"
"b6f59b70eef0992df37f8db891d4b283"
"09baff956ebd1c391c7f71e9bd768edd")
# With luabinaries MinGW-W64 builds the .dll/.a need to be moved to bin/lib set (pkg_opensuse_root "http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Factory/noarch")
# manually, and note that CMake 3.10.0 FindLua.cmake can't find Lua 5.4; set (pkg_opensuse_urls
# in any case there is no pkg-config file "${pkg_opensuse_root}/mingw32-libjson-glib-0.12.0-3.1.noarch.rpm"
set (pkg_mingw_lua_root "http://sourceforge.net/projects/mingw/files/MinGW/Extension") "${pkg_opensuse_root}/mingw32-json-glib-devel-0.12.0-3.1.noarch.rpm")
set (pkg_opensuse_strip "usr/i686-pc-mingw32/sys-root/mingw")
set (pkg_opensuse_md5
"df41a913984b865a46d234ad59703c8c"
"13702ee3e22f79f42948ec5cbb6e23cb")
set (pkg_mingw_lua_root "http://sourceforge.net/projects/mingw-cross/files/%5BLIB%5D%20Lua")
set (pkg_mingw_lua_name "mingw32-lua-5.1.4-2")
set (pkg_mingw_lua_urls set (pkg_mingw_lua_urls
"${pkg_mingw_lua_root}/lua/lua-5.2.0-1/lua-5.2.0-1-mingw32-dll-52.tar.xz" "${pkg_mingw_lua_root}/${pkg_mingw_lua_name}/${pkg_mingw_lua_name}.zip")
"${pkg_mingw_lua_root}/lua/lua-5.2.0-1/lua-5.2.0-1-mingw32-dev.tar.xz") set (pkg_mingw_lua_strip ${pkg_mingw_lua_name})
set (pkg_mingw_lua_md5 set (pkg_mingw_lua_md5
"150b27cab05b78ba40bbd7225630c00d" "7deb1f62a9631871e9b90c0419c2e2bb")
"6abe77c1e1a783075fe73c53b7c235fb")
# Stage 1: fetch missing packages # Stage 1: fetch missing packages
foreach (pkg_set ${pkg_list}) foreach (pkg_set ${pkg_list})
@ -53,19 +82,16 @@ foreach (pkg_set ${pkg_list})
set (filename ${pkg_dir}/${basename}) set (filename ${pkg_dir}/${basename})
if (NOT pkg_md5) if (NOT pkg_md5)
message (WARNING "MD5 checksum missing for ${basename}") message (WARNING "Checksum missing for ${basename}")
set (pkg_md5_sum)
set (pkg_md5_param) set (pkg_md5_param)
else () else (NOT pkg_md5)
list (GET pkg_md5 0 pkg_md5_sum) list (GET pkg_md5 0 pkg_md5_param)
list (REMOVE_AT pkg_md5 0) list (REMOVE_AT pkg_md5 0)
set (pkg_md5_param EXPECTED_MD5 ${pkg_md5_sum}) set (pkg_md5_param EXPECTED_MD5 ${pkg_md5_param})
endif () endif (NOT pkg_md5)
if (NOT EXISTS ${filename}) if (NOT EXISTS ${filename})
message (STATUS "Downloading ${url}...") message (STATUS "Downloading ${url}...")
# TODO: on Windows XP, we can't download https://curl.se/windows/
# but it would be somewhat nice to be able to detect it in PATH
file (DOWNLOAD ${url} ${filename} STATUS status ${pkg_md5_param}) file (DOWNLOAD ${url} ${filename} STATUS status ${pkg_md5_param})
list (GET status 0 status_errno) list (GET status 0 status_errno)
@ -73,40 +99,73 @@ foreach (pkg_set ${pkg_list})
if (status_errno) if (status_errno)
file (REMOVE ${filename}) file (REMOVE ${filename})
message (FATAL_ERROR "Download failed: ${status_msg}") message (FATAL_ERROR "Download failed: ${status_msg}")
endif () endif (status_errno)
elseif (pkg_md5_sum) endif (NOT EXISTS ${filename})
execute_process (COMMAND ${CMAKE_COMMAND} -E md5sum ${filename} endforeach (url)
OUTPUT_VARIABLE output) endforeach (pkg_set)
if (NOT output MATCHES "^${pkg_md5_sum}")
message (FATAL_ERROR "MD5 mismatch for ${basename}")
endif ()
endif ()
endforeach ()
endforeach ()
# Stage 2: extract the rest of packages if (NOT WIN32)
message (FATAL_ERROR "Must run on Windows to extract packages; aborting")
endif (NOT WIN32)
# Stage 2: setup bsdtar first (RPM support)
file (MAKE_DIRECTORY ${tmp_dir})
foreach (url ${pkg_bsdtar_urls})
get_filename_component (filename ${url} NAME)
message (STATUS "Extracting ${filename}...")
set (filename ${pkg_dir}/${filename})
execute_process (COMMAND ${CMAKE_COMMAND} -E tar xf ${filename}
WORKING_DIRECTORY ${tmp_dir}
RESULT_VARIABLE status)
if (status)
message (FATAL_ERROR "Extraction failed: ${status}")
endif (status)
endforeach (url)
file (COPY ${tmp_dir}/bin/ DESTINATION ${bsdtar_dir})
file (REMOVE_RECURSE ${tmp_dir})
list (REMOVE_ITEM pkg_list "bsdtar")
# Stage 3: extract the rest of packages
foreach (pkg_set ${pkg_list}) foreach (pkg_set ${pkg_list})
foreach (url ${pkg_${pkg_set}_urls}) foreach (url ${pkg_${pkg_set}_urls})
get_filename_component (filename ${url} NAME) get_filename_component (filename ${url} NAME)
message (STATUS "Extracting ${filename}...") message (STATUS "Extracting ${filename}...")
set (filename ${pkg_dir}/${filename}) set (filename ${pkg_dir}/${filename})
execute_process (COMMAND ${CMAKE_COMMAND} -E tar xf ${filename}
if (pkg_${pkg_set}_strip)
file (MAKE_DIRECTORY ${tmp_dir})
execute_process (COMMAND ${bsdtar_executable} -xf ${filename}
WORKING_DIRECTORY ${tmp_dir}
RESULT_VARIABLE status)
file (COPY ${tmp_dir}/${pkg_${pkg_set}_strip}/
DESTINATION ${working_dir})
file (REMOVE_RECURSE ${tmp_dir})
else (pkg_${pkg_set}_strip)
execute_process (COMMAND ${bsdtar_executable} -xf ${filename}
WORKING_DIRECTORY ${working_dir} WORKING_DIRECTORY ${working_dir}
RESULT_VARIABLE status) RESULT_VARIABLE status)
endif (pkg_${pkg_set}_strip)
if (status) if (status)
message (FATAL_ERROR "Extraction failed: ${status}") message (FATAL_ERROR "Extraction failed: ${status}")
endif () endif (status)
endforeach () endforeach (url)
endforeach () endforeach (pkg_set)
# Stage 4: final touches
file (WRITE ${working_dir}/etc/gtk-2.0/gtkrc
"gtk-theme-name = \"MS-Windows\"")
set (gdk_pixbuf_libdir lib/gdk-pixbuf-2.0/2.10.0)
set (ENV{GDK_PIXBUF_MODULE_FILE} ${gdk_pixbuf_libdir}/loaders.cache)
set (ENV{GDK_PIXBUF_MODULEDIR} ${gdk_pixbuf_libdir}/loaders)
execute_process (COMMAND
${working_dir}/bin/gdk-pixbuf-query-loaders --update-cache
WORKING_DIRECTORY "${working_dir}"
RESULT_VARIABLE result)
if (result)
message (FATAL_ERROR "gdk-pixbuf-query-loaders failed")
endif (result)
# Stage 3: final touches
# We have to fix the prefix path as it is completely wrong everywhere
file (GLOB files ${working_dir}/lib/pkgconfig/*.pc)
foreach (file ${files})
message (STATUS "Fixing ${file}...")
file (READ ${file} file_content)
string (REGEX REPLACE "prefix=[^\r\n]*(.*)" "prefix=${working_dir}\\1"
file_content_fixed "${file_content}")
file (WRITE ${file} "${file_content_fixed}")
endforeach ()

View File

@ -1,76 +0,0 @@
#!/bin/sh -e
# Win64Depends.sh: download dependencies from MSYS2 for cross-compilation.
# Dependencies: AWK, sed, sha256sum, cURL, bsdtar, wine64
repository=https://repo.msys2.org/mingw/mingw64/
status() {
echo "$(tput bold)-- $*$(tput sgr0)"
}
dbsync() {
status Fetching repository DB
[ -f db.tsv ] || curl -# "$repository/mingw64.db" | bsdtar -xOf- | awk '
function flush() { print f["%NAME%"] f["%FILENAME%"] f["%DEPENDS%"] }
NR > 1 && $0 == "%FILENAME%" { flush(); for (i in f) delete f[i] }
!/^[^%]/ { field = $0; next } { f[field] = f[field] $0 "\t" }
field == "%SHA256SUM%" { path = "*packages/" f["%FILENAME%"]
sub(/\t$/, "", path); print $0, path > "db.sums" } END { flush() }
' > db.tsv
}
fetch() {
status Resolving "$@"
mkdir -p packages
awk -F'\t' 'function get(name, i, a) {
if (visited[name]++ || !(name in filenames)) return
print filenames[name]; split(deps[name], a); for (i in a) get(a[i])
} BEGIN { while ((getline < "db.tsv") > 0) {
filenames[$1] = $2; deps[$1] = ""; for (i = 3; i <= NF; i++) {
gsub(/[<=>].*/, "", $i); deps[$1] = deps[$1] $i FS }
} for (i = 0; i < ARGC; i++) get(ARGV[i]) }' "$@" | tee db.want | \
while IFS= read -r name
do
status Fetching "$name"
[ -f "packages/$name" ] || curl -#o "packages/$name" "$repository/$name"
done
}
verify() {
status Verifying checksums
sha256sum --ignore-missing --quiet -c db.sums
}
extract() {
status Extracting packages
for subdir in *
do [ -d "$subdir" -a "$subdir" != packages ] && rm -rf -- "$subdir"
done
while IFS= read -r name
do bsdtar -xf "packages/$name" --strip-components 1
done < db.want
}
configure() {
status Configuring packages
glib-compile-schemas share/glib-2.0/schemas
wine64 bin/gdk-pixbuf-query-loaders.exe \
> lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
# pkgconf has a command line option for this, but CMake can't pass it.
sed -i "s|^prefix=/mingw64|prefix=$(pwd)|" \
share/pkgconfig/*.pc lib/pkgconfig/*.pc
}
mkdir -p win32-depends
cd win32-depends
dbsync
fetch mingw-w64-x86_64-gtk3 mingw-w64-x86_64-lua \
mingw-w64-x86_64-libwinpthread-git # Because we don't do "provides"?
verify
extract
configure
status Success
# XXX: Why is this override needed to run some GLib-based things under wine64?
unset XDG_DATA_DIRS

View File

@ -1,156 +0,0 @@
# - Find cppcheck
# This module looks for cppcheck.
# This module defines the following variables:
#
# CPPCHECK_FOUND - Set to TRUE when cppcheck is found.
# CPPCHECK_EXECUTABLE - Path to the executable.
#
# and a convenience function for calling the utility:
#
# GENERATE_CPPCHECK(SOURCES <sources to check...>
# [SUPPRESSION_FILE <file>]
# [ENABLE_IDS <id...>]
# [TARGET_NAME <name>]
# [INCLUDES <dir...>])
#
# This generates a "cppcheck" target that executes cppcheck on the specified
# sources. Sources may be either file names or directories containing files
# where all C/++ files will be parsed automatically. Use directories whenever
# possible because there is a limitation in arguments to pass to the cppcheck
# binary.
#
# SUPPRESSION_FILE may be given additionally to specify suppressions for
# cppcheck. The sources mentioned in the suppression file must be in the same
# format as given for SOURCES. This means if you specify them relative to
# CMAKE_CURRENT_SOURCE_DIR, then the same relative paths must be used in the
# suppression file.
#
# ENABLE_IDS allows to specify which additional cppcheck check ids to execute,
# e.g. all or style.
#
# With TARGET_NAME a different name for the generated check target can be
# specified. This is useful if several calls to this function are made in one
# CMake project, as otherwise the target names would collide.
#
# Additional include directories for the cppcheck program can be given with
# INCLUDES.
#
# cppcheck will be executed with CMAKE_CURRENT_SOURCE_DIR as working directory.
#
# This function can be called even if cppcheck wasn't found. In that case no
# target is created.
#
#
#=============================================================================
# Copyright 2011 Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
# Copyright 2012 Přemysl Eric Janouch <p at janouch dot name>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
#=============================================================================
find_program (CPPCHECK_EXECUTABLE cppcheck)
mark_as_advanced (CPPCHECK_EXECUTABLE)
include (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (CppCheck DEFAULT_MSG CPPCHECK_EXECUTABLE)
include (ProcessArguments)
function (GENERATE_CPPCHECK)
if (NOT CPPCHECK_FOUND)
return ()
endif (NOT CPPCHECK_FOUND)
# Parse arguments given to this function
set (__names SOURCES SUPPRESION_FILE ENABLE_IDS TARGET_NAME INCLUDES)
set (__need YES NO NO NO NO)
set (__want 1 1 1 1 1)
set (__more YES NO YES NO YES)
set (__skip 0 0 0 0 0)
set (__argv ${ARGV})
PROCESS_ARGUMENTS (__argv __names __need __want __more __skip "opt_")
# Get target name
set (target_name "cppcheck")
set (target_name_suffix "")
if (opt_target_name)
set (target_name ${opt_target_name_param})
set (target_suffix "-${target_name}")
endif (opt_target_name)
set (cppcheck_base "${PROJECT_BINARY_DIR}/cppcheck${target_suffix}")
set (cppcheck_report_file "${cppcheck_base}-report.log")
set (cppcheck_wrapper_script "${cppcheck_base}.cmake")
# Prepare a command line for cppcheck
set (source_args ${opt_sources_param})
set (options "--inline-suppr")
# Suppression argument
if (opt_suppression_file)
get_filename_component (abs "${opt_suppression_file_param}" ABSOLUTE)
set (options "${options} --suppressions \"${abs}\"")
endif (opt_suppression_file)
# Includes
foreach (include ${opt_includes_param})
set (options "${options} -I \"${include}\"")
endforeach (include)
# Enabled ids
if (opt_enable_ids)
set (id_list "")
foreach (id ${opt_enable_ids_param})
set (id_list "${id_list},${id}")
endforeach (id)
string (SUBSTRING ${id_list} 1 -1 id_list)
set (options "${options} \"--enable=${id_list}\"")
endif (opt_enable_ids)
# Create a wrapper script which redirects stderr of cppcheck to a file
file (WRITE ${cppcheck_wrapper_script} "
execute_process (
COMMAND \"${CPPCHECK_EXECUTABLE}\" ${options} ${source_args}
RESULT_VARIABLE exit_code
ERROR_VARIABLE error_out
WORKING_DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}\")
if (exit_code)
message (FATAL_ERROR \"Error executing cppcheck\")
endif (exit_code)
if (error_out)
message (\"\\nDetected errors:\\n\${error_out}\")
endif (error_out)
file (WRITE \"${cppcheck_report_file}\" \"\${error_out}\")
")
add_custom_target (${target_name}
COMMAND ${CMAKE_COMMAND} -P "${cppcheck_wrapper_script}"
DEPENDS "${cppcheck_wrapper_script}"
COMMENT "Calling cppcheck static code analyzer" VERBATIM)
endfunction (GENERATE_CPPCHECK)

588
cmake/FindGTK2.cmake Normal file
View File

@ -0,0 +1,588 @@
# - FindGTK2.cmake
# This module can find the GTK2 widget libraries and several of its other
# optional components like gtkmm, glade, and glademm.
#
# NOTE: If you intend to use version checking, CMake 2.6.2 or later is
# required.
#
# Specify one or more of the following components
# as you call this find module. See example below.
#
# gtk
# gtkmm
# glade
# glademm
#
# The following variables will be defined for your use
#
# GTK2_FOUND - Were all of your specified components found?
# GTK2_INCLUDE_DIRS - All include directories
# GTK2_LIBRARIES - All libraries
#
# GTK2_VERSION - The version of GTK2 found (x.y.z)
# GTK2_MAJOR_VERSION - The major version of GTK2
# GTK2_MINOR_VERSION - The minor version of GTK2
# GTK2_PATCH_VERSION - The patch version of GTK2
#
# Optional variables you can define prior to calling this module:
#
# GTK2_DEBUG - Enables verbose debugging of the module
# GTK2_SKIP_MARK_AS_ADVANCED - Disable marking cache variables as advanced
# GTK2_ADDITIONAL_SUFFIXES - Allows defining additional directories to
# search for include files
#
#=================
# Example Usage:
#
# Call find_package() once, here are some examples to pick from:
#
# Require GTK 2.6 or later
# find_package(GTK2 2.6 REQUIRED gtk)
#
# Require GTK 2.10 or later and Glade
# find_package(GTK2 2.10 REQUIRED gtk glade)
#
# Search for GTK/GTKMM 2.8 or later
# find_package(GTK2 2.8 COMPONENTS gtk gtkmm)
#
# if(GTK2_FOUND)
# include_directories(${GTK2_INCLUDE_DIRS})
# add_executable(mygui mygui.cc)
# target_link_libraries(mygui ${GTK2_LIBRARIES})
# endif()
#
#=============================================================================
# Copyright 2009 Kitware, Inc.
# Copyright 2008-2009 Philip Lowman <philip@yhbt.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# Version 1.2 (8/30/2010) (CMake 2.8.3)
# * Merge patch for detecting gdk-pixbuf library (split off
# from core GTK in 2.21). Thanks to Vincent Untz for the patch
# and Ricardo Cruz for the heads up.
# Version 1.1 (8/19/2010) (CMake 2.8.3)
# * Add support for detecting GTK2 under macports (thanks to Gary Kramlich)
# Version 1.0 (8/12/2010) (CMake 2.8.3)
# * Add support for detecting new pangommconfig.h header file
# (Thanks to Sune Vuorela & the Debian Project for the patch)
# * Add support for detecting fontconfig.h header
# * Call find_package(Freetype) since it's required
# * Add support for allowing users to add additional library directories
# via the GTK2_ADDITIONAL_SUFFIXES variable (kind of a future-kludge in
# case the GTK developers change versions on any of the directories in the
# future).
# Version 0.8 (1/4/2010)
# * Get module working under MacOSX fink by adding /sw/include, /sw/lib
# to PATHS and the gobject library
# Version 0.7 (3/22/09)
# * Checked into CMake CVS
# * Added versioning support
# * Module now defaults to searching for GTK if COMPONENTS not specified.
# * Added HKCU prior to HKLM registry key and GTKMM specific environment
# variable as per mailing list discussion.
# * Added lib64 to include search path and a few other search paths where GTK
# may be installed on Unix systems.
# * Switched to lowercase CMake commands
# * Prefaced internal variables with _GTK2 to prevent collision
# * Changed internal macros to functions
# * Enhanced documentation
# Version 0.6 (1/8/08)
# Added GTK2_SKIP_MARK_AS_ADVANCED option
# Version 0.5 (12/19/08)
# Second release to cmake mailing list
#=============================================================
# _GTK2_GET_VERSION
# Internal function to parse the version number in gtkversion.h
# _OUT_major = Major version number
# _OUT_minor = Minor version number
# _OUT_micro = Micro version number
# _gtkversion_hdr = Header file to parse
#=============================================================
function(_GTK2_GET_VERSION _OUT_major _OUT_minor _OUT_micro _gtkversion_hdr)
file(READ ${_gtkversion_hdr} _contents)
if(_contents)
string(REGEX REPLACE ".*#define GTK_MAJOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_major} "${_contents}")
string(REGEX REPLACE ".*#define GTK_MINOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_minor} "${_contents}")
string(REGEX REPLACE ".*#define GTK_MICRO_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_micro} "${_contents}")
if(NOT ${_OUT_major} MATCHES "[0-9]+")
message(FATAL_ERROR "Version parsing failed for GTK2_MAJOR_VERSION!")
endif()
if(NOT ${_OUT_minor} MATCHES "[0-9]+")
message(FATAL_ERROR "Version parsing failed for GTK2_MINOR_VERSION!")
endif()
if(NOT ${_OUT_micro} MATCHES "[0-9]+")
message(FATAL_ERROR "Version parsing failed for GTK2_MICRO_VERSION!")
endif()
set(${_OUT_major} ${${_OUT_major}} PARENT_SCOPE)
set(${_OUT_minor} ${${_OUT_minor}} PARENT_SCOPE)
set(${_OUT_micro} ${${_OUT_micro}} PARENT_SCOPE)
else()
message(FATAL_ERROR "Include file ${_gtkversion_hdr} does not exist")
endif()
endfunction()
#=============================================================
# _GTK2_FIND_INCLUDE_DIR
# Internal function to find the GTK include directories
# _var = variable to set
# _hdr = header file to look for
#=============================================================
function(_GTK2_FIND_INCLUDE_DIR _var _hdr)
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"_GTK2_FIND_INCLUDE_DIR( ${_var} ${_hdr} )")
endif()
set(_relatives
# If these ever change, things will break.
${GTK2_ADDITIONAL_SUFFIXES}
glibmm-2.4
glib-2.0
atk-1.0
atkmm-1.6
cairo
cairomm-1.0
gdk-pixbuf-2.0
gdkmm-2.4
giomm-2.4
gtk-2.0
gtkmm-2.4
libglade-2.0
libglademm-2.4
pango-1.0
pangomm-1.4
sigc++-2.0
)
set(_suffixes)
foreach(_d ${_relatives})
list(APPEND _suffixes ${_d})
list(APPEND _suffixes ${_d}/include) # for /usr/lib/gtk-2.0/include
endforeach()
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"include suffixes = ${_suffixes}")
endif()
find_path(${_var} ${_hdr}
PATHS
/usr/local/lib64
/usr/local/lib
/usr/lib64
/usr/lib
/opt/gnome/include
/opt/gnome/lib
/opt/openwin/include
/usr/openwin/lib
/sw/include
/sw/lib
/opt/local/include
/opt/local/lib
$ENV{GTKMM_BASEPATH}/include
$ENV{GTKMM_BASEPATH}/lib
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/include
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/include
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
PATH_SUFFIXES
${_suffixes}
)
if(${_var})
set(GTK2_INCLUDE_DIRS ${GTK2_INCLUDE_DIRS} ${${_var}} PARENT_SCOPE)
if(NOT GTK2_SKIP_MARK_AS_ADVANCED)
mark_as_advanced(${_var})
endif()
endif()
endfunction(_GTK2_FIND_INCLUDE_DIR)
#=============================================================
# _GTK2_FIND_LIBRARY
# Internal function to find libraries packaged with GTK2
# _var = library variable to create
#=============================================================
function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version)
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"_GTK2_FIND_LIBRARY( ${_var} ${_lib} ${_expand_vc} ${_append_version} )")
endif()
# Not GTK versions per se but the versions encoded into Windows
# import libraries (GtkMM 2.14.1 has a gtkmm-vc80-2_4.lib for example)
# Also the MSVC libraries use _ for . (this is handled below)
set(_versions 2.20 2.18 2.16 2.14 2.12
2.10 2.8 2.6 2.4 2.2 2.0
1.20 1.18 1.16 1.14 1.12
1.10 1.8 1.6 1.4 1.2 1.0)
set(_library)
set(_library_d)
set(_library ${_lib})
if(_expand_vc)
# Add vc80/vc90 midfixes
if(MSVC80)
set(_library ${_library}-vc80)
set(_library_d ${_library}-d)
elseif(MSVC90)
set(_library ${_library}-vc90)
set(_library_d ${_library}-d)
endif()
endif()
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"After midfix addition = ${_library} and ${_library_d}")
endif()
set(_lib_list)
set(_libd_list)
if(_append_version)
foreach(_ver ${_versions})
list(APPEND _lib_list "${_library}-${_ver}")
list(APPEND _libd_list "${_library_d}-${_ver}")
endforeach()
else()
set(_lib_list ${_library})
set(_libd_list ${_library_d})
endif()
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"library list = ${_lib_list} and library debug list = ${_libd_list}")
endif()
# For some silly reason the MSVC libraries use _ instead of .
# in the version fields
if(_expand_vc AND MSVC)
set(_no_dots_lib_list)
set(_no_dots_libd_list)
foreach(_l ${_lib_list})
string(REPLACE "." "_" _no_dots_library ${_l})
list(APPEND _no_dots_lib_list ${_no_dots_library})
endforeach()
# And for debug
set(_no_dots_libsd_list)
foreach(_l ${_libd_list})
string(REPLACE "." "_" _no_dots_libraryd ${_l})
list(APPEND _no_dots_libd_list ${_no_dots_libraryd})
endforeach()
# Copy list back to original names
set(_lib_list ${_no_dots_lib_list})
set(_libd_list ${_no_dots_libd_list})
endif()
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"While searching for ${_var}, our proposed library list is ${_lib_list}")
endif()
find_library(${_var}
NAMES ${_lib_list}
PATHS
/opt/gnome/lib
/opt/gnome/lib64
/usr/openwin/lib
/usr/openwin/lib64
/sw/lib
$ENV{GTKMM_BASEPATH}/lib
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
)
if(_expand_vc AND MSVC)
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"While searching for ${_var}_DEBUG our proposed library list is ${_libd_list}")
endif()
find_library(${_var}_DEBUG
NAMES ${_libd_list}
PATHS
$ENV{GTKMM_BASEPATH}/lib
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
)
if(${_var} AND ${_var}_DEBUG)
if(NOT GTK2_SKIP_MARK_AS_ADVANCED)
mark_as_advanced(${_var}_DEBUG)
endif()
set(GTK2_LIBRARIES ${GTK2_LIBRARIES} optimized ${${_var}} debug ${${_var}_DEBUG})
set(GTK2_LIBRARIES ${GTK2_LIBRARIES} PARENT_SCOPE)
endif()
else()
if(NOT GTK2_SKIP_MARK_AS_ADVANCED)
mark_as_advanced(${_var})
endif()
set(GTK2_LIBRARIES ${GTK2_LIBRARIES} ${${_var}})
set(GTK2_LIBRARIES ${GTK2_LIBRARIES} PARENT_SCOPE)
# Set debug to release
set(${_var}_DEBUG ${${_var}})
set(${_var}_DEBUG ${${_var}} PARENT_SCOPE)
endif()
endfunction(_GTK2_FIND_LIBRARY)
#=============================================================
#
# main()
#
set(GTK2_FOUND)
set(GTK2_INCLUDE_DIRS)
set(GTK2_LIBRARIES)
if(NOT GTK2_FIND_COMPONENTS)
# Assume they only want GTK
set(GTK2_FIND_COMPONENTS gtk)
endif()
#
# If specified, enforce version number
#
if(GTK2_FIND_VERSION)
cmake_minimum_required(VERSION 2.6.2)
set(GTK2_FAILED_VERSION_CHECK true)
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"Searching for version ${GTK2_FIND_VERSION}")
endif()
_GTK2_FIND_INCLUDE_DIR(GTK2_GTK_INCLUDE_DIR gtk/gtk.h)
if(GTK2_GTK_INCLUDE_DIR)
_GTK2_GET_VERSION(GTK2_MAJOR_VERSION
GTK2_MINOR_VERSION
GTK2_PATCH_VERSION
${GTK2_GTK_INCLUDE_DIR}/gtk/gtkversion.h)
set(GTK2_VERSION
${GTK2_MAJOR_VERSION}.${GTK2_MINOR_VERSION}.${GTK2_PATCH_VERSION})
if(GTK2_FIND_VERSION_EXACT)
if(GTK2_VERSION VERSION_EQUAL GTK2_FIND_VERSION)
set(GTK2_FAILED_VERSION_CHECK false)
endif()
else()
if(GTK2_VERSION VERSION_EQUAL GTK2_FIND_VERSION OR
GTK2_VERSION VERSION_GREATER GTK2_FIND_VERSION)
set(GTK2_FAILED_VERSION_CHECK false)
endif()
endif()
else()
# If we can't find the GTK include dir, we can't do version checking
if(GTK2_FIND_REQUIRED AND NOT GTK2_FIND_QUIETLY)
message(FATAL_ERROR "Could not find GTK2 include directory")
endif()
return()
endif()
if(GTK2_FAILED_VERSION_CHECK)
if(GTK2_FIND_REQUIRED AND NOT GTK2_FIND_QUIETLY)
if(GTK2_FIND_VERSION_EXACT)
message(FATAL_ERROR "GTK2 version check failed. Version ${GTK2_VERSION} was found, version ${GTK2_FIND_VERSION} is needed exactly.")
else()
message(FATAL_ERROR "GTK2 version check failed. Version ${GTK2_VERSION} was found, at least version ${GTK2_FIND_VERSION} is required")
endif()
endif()
# If the version check fails, exit out of the module here
return()
endif()
endif()
#
# Find all components
#
find_package(Freetype)
list(APPEND GTK2_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS})
list(APPEND GTK2_LIBRARIES ${FREETYPE_LIBRARIES})
foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
if(_GTK2_component STREQUAL "gtk")
_GTK2_FIND_INCLUDE_DIR(GTK2_GLIB_INCLUDE_DIR glib.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GLIBCONFIG_INCLUDE_DIR glibconfig.h)
_GTK2_FIND_LIBRARY (GTK2_GLIB_LIBRARY glib false true)
_GTK2_FIND_LIBRARY (GTK2_GIO_LIBRARY gio false true)
_GTK2_FIND_INCLUDE_DIR(GTK2_GOBJECT_INCLUDE_DIR gobject/gobject.h)
_GTK2_FIND_LIBRARY (GTK2_GOBJECT_LIBRARY gobject false true)
_GTK2_FIND_INCLUDE_DIR(GTK2_GDK_PIXBUF_INCLUDE_DIR gdk-pixbuf/gdk-pixbuf.h)
_GTK2_FIND_LIBRARY (GTK2_GDK_PIXBUF_LIBRARY gdk_pixbuf false true)
_GTK2_FIND_INCLUDE_DIR(GTK2_GDK_INCLUDE_DIR gdk/gdk.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GDKCONFIG_INCLUDE_DIR gdkconfig.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GTK_INCLUDE_DIR gtk/gtk.h)
if(UNIX)
_GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-x11 false true)
_GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-x11 false true)
else()
_GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-win32 false true)
_GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-win32 false true)
endif()
_GTK2_FIND_INCLUDE_DIR(GTK2_CAIRO_INCLUDE_DIR cairo.h)
_GTK2_FIND_LIBRARY (GTK2_CAIRO_LIBRARY cairo false false)
_GTK2_FIND_INCLUDE_DIR(GTK2_FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_PANGO_INCLUDE_DIR pango/pango.h)
_GTK2_FIND_LIBRARY (GTK2_PANGO_LIBRARY pango false true)
_GTK2_FIND_LIBRARY (GTK2_PANGOCAIRO_LIBRARY pangocairo false true)
_GTK2_FIND_INCLUDE_DIR(GTK2_ATK_INCLUDE_DIR atk/atk.h)
_GTK2_FIND_LIBRARY (GTK2_ATK_LIBRARY atk false true)
elseif(_GTK2_component STREQUAL "gtkmm")
_GTK2_FIND_INCLUDE_DIR(GTK2_GLIBMM_INCLUDE_DIR glibmm.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GLIBMMCONFIG_INCLUDE_DIR glibmmconfig.h)
_GTK2_FIND_LIBRARY (GTK2_GLIBMM_LIBRARY glibmm true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_GDKMM_INCLUDE_DIR gdkmm.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GDKMMCONFIG_INCLUDE_DIR gdkmmconfig.h)
_GTK2_FIND_LIBRARY (GTK2_GDKMM_LIBRARY gdkmm true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_GTKMM_INCLUDE_DIR gtkmm.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GTKMMCONFIG_INCLUDE_DIR gtkmmconfig.h)
_GTK2_FIND_LIBRARY (GTK2_GTKMM_LIBRARY gtkmm true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_CAIROMM_INCLUDE_DIR cairomm/cairomm.h)
_GTK2_FIND_LIBRARY (GTK2_CAIROMM_LIBRARY cairomm true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMM_INCLUDE_DIR pangomm.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMMCONFIG_INCLUDE_DIR pangommconfig.h)
_GTK2_FIND_LIBRARY (GTK2_PANGOMM_LIBRARY pangomm true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++_INCLUDE_DIR sigc++/sigc++.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++CONFIG_INCLUDE_DIR sigc++config.h)
_GTK2_FIND_LIBRARY (GTK2_SIGC++_LIBRARY sigc true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_GIOMM_INCLUDE_DIR giomm.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GIOMMCONFIG_INCLUDE_DIR giommconfig.h)
_GTK2_FIND_LIBRARY (GTK2_GIOMM_LIBRARY giomm true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_ATKMM_INCLUDE_DIR atkmm.h)
_GTK2_FIND_LIBRARY (GTK2_ATKMM_LIBRARY atkmm true true)
elseif(_GTK2_component STREQUAL "glade")
_GTK2_FIND_INCLUDE_DIR(GTK2_GLADE_INCLUDE_DIR glade/glade.h)
_GTK2_FIND_LIBRARY (GTK2_GLADE_LIBRARY glade false true)
elseif(_GTK2_component STREQUAL "glademm")
_GTK2_FIND_INCLUDE_DIR(GTK2_GLADEMM_INCLUDE_DIR libglademm.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GLADEMMCONFIG_INCLUDE_DIR libglademmconfig.h)
_GTK2_FIND_LIBRARY (GTK2_GLADEMM_LIBRARY glademm true true)
else()
message(FATAL_ERROR "Unknown GTK2 component ${_component}")
endif()
endforeach()
#
# Solve for the GTK2 version if we haven't already
#
if(NOT GTK2_FIND_VERSION AND GTK2_GTK_INCLUDE_DIR)
_GTK2_GET_VERSION(GTK2_MAJOR_VERSION
GTK2_MINOR_VERSION
GTK2_PATCH_VERSION
${GTK2_GTK_INCLUDE_DIR}/gtk/gtkversion.h)
set(GTK2_VERSION ${GTK2_MAJOR_VERSION}.${GTK2_MINOR_VERSION}.${GTK2_PATCH_VERSION})
endif()
#
# Try to enforce components
#
set(_GTK2_did_we_find_everything true) # This gets set to GTK2_FOUND
include(FindPackageHandleStandardArgs)
foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
string(TOUPPER ${_GTK2_component} _COMPONENT_UPPER)
if(_GTK2_component STREQUAL "gtk")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "Some or all of the gtk libraries were not found."
GTK2_GTK_LIBRARY
GTK2_GTK_INCLUDE_DIR
GTK2_GLIB_INCLUDE_DIR
GTK2_GLIBCONFIG_INCLUDE_DIR
GTK2_GLIB_LIBRARY
GTK2_GIO_LIBRARY
GTK2_GDK_INCLUDE_DIR
GTK2_GDKCONFIG_INCLUDE_DIR
GTK2_GDK_LIBRARY
)
elseif(_GTK2_component STREQUAL "gtkmm")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "Some or all of the gtkmm libraries were not found."
GTK2_GTKMM_LIBRARY
GTK2_GTKMM_INCLUDE_DIR
GTK2_GTKMMCONFIG_INCLUDE_DIR
GTK2_GLIBMM_INCLUDE_DIR
GTK2_GLIBMMCONFIG_INCLUDE_DIR
GTK2_GLIBMM_LIBRARY
GTK2_GDKMM_INCLUDE_DIR
GTK2_GDKMMCONFIG_INCLUDE_DIR
GTK2_GDKMM_LIBRARY
)
elseif(_GTK2_component STREQUAL "glade")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "The glade library was not found."
GTK2_GLADE_LIBRARY
GTK2_GLADE_INCLUDE_DIR
)
elseif(_GTK2_component STREQUAL "glademm")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "The glademm library was not found."
GTK2_GLADEMM_LIBRARY
GTK2_GLADEMM_INCLUDE_DIR
GTK2_GLADEMMCONFIG_INCLUDE_DIR
)
endif()
if(NOT GTK2_${_COMPONENT_UPPER}_FOUND)
set(_GTK2_did_we_find_everything false)
endif()
endforeach()
if(_GTK2_did_we_find_everything AND NOT GTK2_VERSION_CHECK_FAILED)
set(GTK2_FOUND true)
else()
# Unset our variables.
set(GTK2_FOUND false)
set(GTK2_VERSION)
set(GTK2_VERSION_MAJOR)
set(GTK2_VERSION_MINOR)
set(GTK2_VERSION_PATCH)
set(GTK2_INCLUDE_DIRS)
set(GTK2_LIBRARIES)
endif()
if(GTK2_INCLUDE_DIRS)
list(REMOVE_DUPLICATES GTK2_INCLUDE_DIRS)
endif()

99
cmake/FindGettext.cmake Normal file
View File

@ -0,0 +1,99 @@
# - Find GNU gettext tools
# This module looks for the GNU gettext tools. This module defines the
# following values:
# GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool.
# GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool.
# GETTEXT_FOUND: True if gettext has been found.
#
# Additionally it provides the following macros:
# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN )
# This will create a target "${PROJECT_NAME}_translations" which will
# convert the given input po files into the binary output mo file.
# If the ALL option is used, the translations will also be created
# when building the default target.
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
# Copyright 2010-2011 Přemysl Janouch
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the Kitware nor the names of contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
#=============================================================================
find_program (GETTEXT_MSGMERGE_EXECUTABLE msgmerge)
find_program (GETTEXT_MSGFMT_EXECUTABLE msgfmt)
macro (GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg)
# Make it a real variable, so we can modify it here.
set (_firstPoFile "${_firstPoFileArg}")
set (_gmoFiles)
get_filename_component (_potBasename ${_potFile} NAME_WE)
get_filename_component (_absPotFile ${_potFile} ABSOLUTE)
set (_addToAll)
if (${_firstPoFile} STREQUAL "ALL")
set (_addToAll "ALL")
set (_firstPoFile)
endif (${_firstPoFile} STREQUAL "ALL")
foreach (_currentPoFile ${_firstPoFile} ${ARGN})
get_filename_component (_absFile ${_currentPoFile} ABSOLUTE)
get_filename_component (_abs_PATH ${_absFile} PATH)
get_filename_component (_lang ${_absFile} NAME_WE)
set (_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
# msgmerge versions older than 0.11 don't actually support --update
# and --backup, let's try to workaround that (tested on 0.10.40).
execute_process (COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} -V
OUTPUT_VARIABLE _msgmergeVersion)
string (REGEX MATCH "0[.][0-9]+" _msgmergeVersion ${_msgmergeVersion})
if ("${_msgmergeVersion}" MATCHES "[.]10|[.][0-9]")
set (_msgmergeParams --quiet -s
${_absFile} -o ${_absFile} ${_absPotFile})
else ("${_msgmergeVersion}" MATCHES "[.]10|[.][0-9]")
set (_msgmergeParams --quiet --update --backup=none -s
${_absFile} ${_absPotFile})
endif ("${_msgmergeVersion}" MATCHES "[.]10|[.][0-9]")
add_custom_command (
OUTPUT ${_gmoFile}
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} ${_msgmergeParams}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
DEPENDS ${_absPotFile} ${_absFile}
)
install (FILES ${_gmoFile} DESTINATION
share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
set (_gmoFiles ${_gmoFiles} ${_gmoFile})
endforeach (_currentPoFile)
add_custom_target (${PROJECT_NAME}_translations ${_addToAll}
DEPENDS ${_gmoFiles})
endmacro (GETTEXT_CREATE_TRANSLATIONS)
include (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (Gettext DEFAULT_MSG
GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE)

373
cmake/FindGtkDoc.cmake Normal file
View File

@ -0,0 +1,373 @@
# - Finding gtk-doc and building documentation
# This module provides the following function:
#
# GTK_DOC_RUN (
# [ALL]
# [MODULE <module-name>]
# [WORKING_DIR <working-dir>]
# SOURCE_DIRS <source-dir> ...
# [IGNORE_FILES <file> ...]
# [SCANGOBJ <library> [<link-libraries> ...]]
# [{SGML | XML} [<mkdb-output-dir> [<mkdb-options>]]
# [HTML <html-output-dir> <backend-options>]]
# )
#
# The function creates a target named <module-name>_gtkdocize
# which will build the documentation as specified by parameters.
#
# ALL - always build the target
# MODULE - the name of the module
# CMAKE_PROJECT_NAME by default
# WORKING_DIR - path to the working directory
# CMAKE_CURRENT_BINARY_DIR by default
# SOURCE_DIRS - documentation sources
# IGNORE_FILES - ignore these files in the process
# SCANGOBJ - build an object hierarchy scanner
# SGML - make SGML output in the spec. directory
# XML - make XML output in the spec. directory
# HTML - make HTML output in the spec. directory
# (requires either SGML or XML)
#
# Also creates these virtual symbolic outputs if appropriate:
# <module-name>_gtkdocize_scan
# <module-name>_gtkdocize_scan_rebuild_types
# <module-name>_gtkdocize_scan_rebuild_sections
# <module-name>_gtkdocize_scan_gobject
# <module-name>_gtkdocize_mkdb
# <module-name>_gtkdocize_mkhtml
#
#
#=============================================================================
# Copyright Přemysl Janouch 2010 - 2011
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
#=============================================================================
# TODO
# ====
# - Since it doesn't work without the full Unix environment,
# it might be actually proper to use pkg-config
#
# - <module-name>_gtkdocize_fixxref
# - gtkdoc-rebase
# - Content files (included by the main SGML file)
#
find_program (GTK_DOC_SCAN_EXECUTABLE "gtkdoc-scan")
find_program (GTK_DOC_SCANGOBJ_EXECUTABLE "gtkdoc-scangobj")
find_program (GTK_DOC_MKTMPL_EXECUTABLE "gtkdoc-mktmpl")
find_program (GTK_DOC_MKDB_EXECUTABLE "gtkdoc-mkdb")
find_program (GTK_DOC_MKHTML_EXECUTABLE "gtkdoc-mkhtml")
find_program (GTK_DOC_FIXXREF_EXECUTABLE "gtkdoc-fixxref")
mark_as_advanced (GTK_DOC_SCAN_EXECUTABLE GTK_DOC_SCANGOBJ_EXECUTABLE
GTK_DOC_MKTMPL_EXECUTABLE GTK_DOC_MKDB_EXECUTABLE
GTK_DOC_MKHTML_EXECUTABLE GTK_DOC_FIXXREF_EXECUTABLE)
include (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (GTK_DOC DEFAULT_MSG GTK_DOC_SCAN_EXECUTABLE)
include (ProcessArguments)
function (GTK_DOC_RUN)
# Parse arguments given to this function
set (__names ALL MODULE WORKING_DIR SOURCE_DIRS IGNORE_FILES)
set (__need NO NO NO YES NO)
set (__want 0 1 1 1 1)
set (__more NO NO NO YES YES)
set (__skip 0 0 0 0 0)
list (APPEND __names SCANGOBJ SGML XML HTML)
list (APPEND __need NO NO NO NO)
list (APPEND __want 1 0 0 1)
list (APPEND __more YES YES YES YES)
list (APPEND __skip 0 1 0 0)
set (__argv ${ARGV})
PROCESS_ARGUMENTS (__argv __names __need __want __more __skip "_opt_")
# Further process the arguments
if (_opt_all)
set (_all ALL)
else (_opt_all)
set (_all)
endif (_opt_all)
if (_opt_module)
set (_module_name ${_opt_module_param})
else (_opt_module)
set (_module_name ${CMAKE_PROJECT_NAME})
endif (_opt_module)
if (_opt_working_dir)
set (_working_dir ${_opt_working_dir_param})
else (_opt_working_dir)
set (_working_dir ${CMAKE_CURRENT_BINARY_DIR})
endif (_opt_working_dir)
set (_source_dirs)
foreach (_dir ${_opt_source_dirs_param})
list (APPEND _source_dirs "--source-dir" "${_dir}")
endforeach (_dir)
set (_ignores)
if (_opt_ignore_files)
foreach (_file ${_opt_ignore_files_param})
set (_ignores "${_ignores} ${_file}")
endforeach (_file)
string (STRIP "${_ignores}" _ignores)
endif (_opt_ignore_files)
if (_opt_sgml)
set (_mkdb_format "sgml")
set (_mkdb_options "${_opt_sgml_param}")
elseif (_opt_xml)
set (_mkdb_format "xml")
set (_mkdb_options "${_opt_xml_param}")
else (_opt_sgml)
set (_mkdb_format OFF)
endif (_opt_sgml)
if (_mkdb_format)
set (_mkdb_driver ${_working_dir}/${_module_name}-docs.${_mkdb_format})
list (LENGTH _mkdb_options _length)
if (${_length} GREATER 0)
list (GET _mkdb_options 0 _mkdb_output_dir)
list (REMOVE_AT _mkdb_options 0)
else (${_length} GREATER 0)
set (_mkdb_output_dir ${_working_dir}/${_mkdb_format})
endif (${_length} GREATER 0)
endif (_mkdb_format)
# The basic target name
set (_target_name ${_module_name}_gtkdocize)
# Scan the source files
set (_scan_target_base
# These files are created if they don't exist
# ${_working_dir}/${_module_name}.types
# ${_working_dir}/${_module_name}-sections.txt
# ${_working_dir}/${_module_name}-overrides.txt
${_working_dir}/${_module_name}-decl.txt
${_working_dir}/${_module_name}-decl-list.txt
COMMAND ${GTK_DOC_SCAN_EXECUTABLE}
--module=${_module_name}
${_source_dirs} "--ignore-headers=${_ignores}"
--output-dir=${_working_dir})
add_custom_command (
OUTPUT ${_target_name}_scan
${_scan_target_base}
COMMENT "Calling gtkdoc-scan" VERBATIM)
# Special target to force rebuild of ${_module_name}.types
add_custom_command (
OUTPUT ${_target_name}_scan_rebuild_types
${_scan_target_base} --rebuild-types
COMMENT "Calling gtkdoc-scan to rebuild types" VERBATIM)
add_custom_target (${_target_name}_rebuild_types
DEPENDS ${_target_name}_scan_rebuild_types)
# Special target to force rebuild of ${_module_name}-sections.txt
add_custom_command (
OUTPUT ${_target_name}_scan_rebuild_sections
${_scan_target_base} --rebuild-sections
COMMENT "Calling gtkdoc-scan to rebuild sections" VERBATIM)
add_custom_target (${_target_name}_rebuild_sections
DEPENDS ${_target_name}_scan_rebuild_sections)
set_source_files_properties (
${_target_name}_scan
${_target_name}_scan_rebuild_types
${_target_name}_scan_rebuild_sections
PROPERTIES SYMBOLIC TRUE)
set (_top_output ${_target_name}_scan)
# Scan the object hierarchy
# This is a terrible hack, but there's no other way around.
if (_opt_scangobj)
# Put all include directories into CFLAGS
set (_cflags)
get_directory_property (_include_dirs INCLUDE_DIRECTORIES)
foreach (_dir ${_include_dirs})
set (_cflags "${_cflags} -I${_dir}")
endforeach (_dir)
# Put all libraries to LDFLAGS
set (_ldflags "-L${CMAKE_CURRENT_BINARY_DIR}")
set (_lib_depends)
set (_lib_dir_used)
foreach (_lib ${_opt_scangobj_param} ${CMAKE_STANDARD_LIBRARIES})
get_filename_component (_lib_dir ${_lib} PATH)
get_filename_component (_lib_name ${_lib} NAME)
# If it's not a target, suppose it's a shared library
get_target_property (_target_type ${_lib_name} TYPE)
if (_target_type)
get_target_property (_lib_output_name ${_lib_name} OUTPUT_NAME)
if (_lib_output_name)
set (_lib_name ${_lib_output_name})
endif (_lib_output_name)
list (APPEND _lib_depends ${_lib_name})
else (_target_type)
list (FIND _lib_dir_used "${_lib_dir}" _lib_dir_found)
if (_lib_dir AND _lib_dir_found EQUAL "-1")
set (_ldflags "${_ldflags} -L${_lib_dir}")
list (APPEND _lib_dir_used ${_lib_dir})
endif (_lib_dir AND _lib_dir_found EQUAL "-1")
string (REGEX REPLACE "^${CMAKE_SHARED_LIBRARY_PREFIX}" ""
_lib_name "${_lib_name}")
string (REGEX REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}\$" ""
_lib_name "${_lib_name}")
endif (_target_type)
set (_ldflags "${_ldflags} -l${_lib_name}")
endforeach (_lib)
add_custom_command (
OUTPUT ${_target_name}_scan_gobject
${_working_dir}/${_module_name}.signals
${_working_dir}/${_module_name}.hierarchy
${_working_dir}/${_module_name}.interfaces
${_working_dir}/${_module_name}.prerequisites
${_working_dir}/${_module_name}.args
COMMAND "CC=${CMAKE_C_COMPILER}" "CFLAGS=${_cflags}"
"LD=${CMAKE_C_COMPILER}" "LDFLAGS=${_ldflags}"
"RUN=" ${GTK_DOC_SCANGOBJ_EXECUTABLE}
--module=${_module_name} --output-dir=${_working_dir}
DEPENDS ${_top_output} ${_lib_depends}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Calling gtkdoc-scangobj")
set_source_files_properties (${_target_name}_scan_gobject
PROPERTIES SYMBOLIC TRUE)
set (_top_output ${_target_name}_scan_gobject)
endif (_opt_scangobj)
# Create XML or SGML files
if (_mkdb_format)
add_custom_command (
OUTPUT ${_target_name}_mkdb
${_mkdb_output_dir}
${_working_dir}/sgml.stamp
${_working_dir}/${_module_name}-undeclared.txt
${_working_dir}/${_module_name}-undocumented.txt
${_working_dir}/${_module_name}-unused.txt
# --outputallsymbols --outputsymbolswithoutsince
# ${_working_dir}/${_module_name}-symbols.txt
# ${_working_dir}/${_module_name}-nosince.txt
COMMAND ${CMAKE_COMMAND} -E remove_directory ${_mkdb_output_dir}
COMMAND ${GTK_DOC_MKDB_EXECUTABLE}
--module=${_module_name}
${_source_dirs} "--ignore-files=${_ignores}"
--output-format=${_mkdb_format}
--output-dir=${_mkdb_output_dir}
${_mkdb_options} --main-sgml-file=${_mkdb_driver}
DEPENDS ${_top_output}
WORKING_DIRECTORY ${_working_dir}
COMMENT "Calling gtkdoc-mkdb" VERBATIM)
set_source_files_properties (${_target_name}_mkdb
PROPERTIES SYMBOLIC TRUE)
set (_top_output ${_target_name}_mkdb)
endif (_mkdb_format)
# Create HTML documentation
if (_opt_html)
if (NOT _mkdb_format)
message (FATAL_ERROR "Given HTML but neither XML nor SGML")
endif (NOT _mkdb_format)
list (GET _opt_html_param 0 _html_output_dir)
list (REMOVE_AT _opt_html_param 0)
add_custom_command (
OUTPUT ${_target_name}_mkhtml
${_html_output_dir}/../html.stamp
# We probably don't want this to be removed either
# ${_html_output_dir}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${_html_output_dir}
COMMAND ${CMAKE_COMMAND} -E make_directory ${_html_output_dir}
COMMAND ${CMAKE_COMMAND} -E chdir ${_html_output_dir}
${GTK_DOC_MKHTML_EXECUTABLE}
${_module_name} ${_mkdb_driver} ${_opt_html_param}
DEPENDS ${_top_output}
COMMENT "Calling gtkdoc-mkhtml" VERBATIM)
set_source_files_properties (${_target_name}_mkhtml
PROPERTIES SYMBOLIC TRUE)
set (_top_output ${_target_name}_mkhtml)
endif (_opt_html)
# gtkdoc-fixxref
# ? copy ${_html_output_dir} to CMAKE_BINARY_DIR,
# run gtkdoc-fixxref in there and install the directory
# -> FIXXREF <output-dir> [INSTALL]
#
#? set (_fixxref_dir ${CMAKE_CURRENT_BINARY_DIR}/html-fixxref)
# add_custom_command (
# OUTPUT ${_target_name}_fixxref
#? ${_fixxref_dir}
#? COMMAND ${CMAKE_COMMAND} -E remove_directory ${_fixxref_dir}
#? COMMAND ${CMAKE_COMMAND} -E copy_directory
#? ${_html_output_dir} ${_fixxref_dir}
# COMMAND ${GTK_DOC_FIXXREF_EXECUTABLE}
# --module=${_module_name}
# --module-dir=${_html_output_dir}
#? --module-dir=${_fixxref_dir}
# DEPENDS ${_html_output_dir}
# WORKING_DIRECTORY ${_working_dir}
# COMMENT "Calling gtkdoc-fixxref" VERBATIM)
#? install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html-fixxref/
#? DESTINATION share/gtk-doc/html/${_module_name})
#& COMPONENT docs) -- see CPack component install
# gtkdoc-rebase -- how to do this?
#
# Probably omit this because source tarball cannot be hooked
# to do some action before.
# -> Custom dist target?
# add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
# -> ${_html_output_dir} could contain online links by default,
# then it could be copied to binary dir and rebased to relative
# * Looks like a very good idea, can work even without gtk-doc
# -> Or it can be first xreffed in the binary dir and then
# converted to online links in ${_html_output_dir}
# * Which one of those should be installed?
# The one in the binary directory or should the
# ${_html_output_dir} be rebased?
# * A rebasing custom command may create the binary directory
# if it doesn't exist
#
# When creating the source tarball for distribution,
# gtkdoc-rebase turns all external links into web-links.
# When installing distributed (pregenerated) docs the same
# application will try to turn links back to local links
# (where those docs are installed).
add_custom_target (${_target_name} ${_all}
DEPENDS ${_top_output})
endfunction (GTK_DOC_RUN)

58
cmake/FindJsonGlib.cmake Normal file
View File

@ -0,0 +1,58 @@
# - Find json-glib
# This module looks for json-glib.
# This module defines the following values:
# JSON_GLIB_FOUND
# JSON_GLIB_INCLUDE_DIRS
# JSON_GLIB_LIBRARIES
#=============================================================================
# Copyright Přemysl Janouch 2010
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
#=============================================================================
find_path (JSON_GLIB_INCLUDE_DIR json-glib/json-glib.h
PATH_SUFFIXES json-glib-1.0)
find_path (JSON_GLIB_INCLUDE_DIR_GOBJECT glib-object.h
PATH_SUFFIXES glib-2.0)
find_path (JSON_GLIB_INCLUDE_DIR_GLIBCONFIG glibconfig.h
PATHS /usr/lib
PATH_SUFFIXES glib-2.0 glib-2.0/include)
find_library (JSON_GLIB_LIBRARIES json-glib-1.0)
include (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (JSON_GLIB DEFAULT_MSG JSON_GLIB_LIBRARIES
JSON_GLIB_INCLUDE_DIR JSON_GLIB_INCLUDE_DIR_GOBJECT JSON_GLIB_INCLUDE_DIR_GLIBCONFIG)
set (JSON_GLIB_INCLUDE_DIRS
${JSON_GLIB_INCLUDE_DIR}
${JSON_GLIB_INCLUDE_DIR_GOBJECT}
${JSON_GLIB_INCLUDE_DIR_GLIBCONFIG})
unset (JSON_GLIB_INCLUDE_DIR CACHE)
unset (JSON_GLIB_INCLUDE_DIR_GOBJECT CACHE)
unset (JSON_GLIB_INCLUDE_DIR_GLIBCONFIG CACHE)
mark_as_advanced (JSON_GLIB_LIBRARIES JSON_GLIB_INCLUDE_DIRS)

38
cmake/FindLibIntl.cmake Normal file
View File

@ -0,0 +1,38 @@
# - Find libintl
# This module looks for libintl.
# This module defines the following values:
# LIBINTL_FOUND
# LIBINTL_LIBRARIES
#=============================================================================
# Copyright Přemysl Janouch 2011
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
#=============================================================================
find_library (LIBINTL_LIBRARIES intl)
include (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (LibIntl DEFAULT_MSG LIBINTL_LIBRARIES)
mark_as_advanced (LIBINTL_LIBRARIES)

View File

@ -22,7 +22,7 @@
# #
#============================================================================= #=============================================================================
# Copyright 2010 Přemysl Eric Janouch # Copyright Přemysl Janouch 2010
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without

View File

@ -9,26 +9,23 @@
#define __CONFIG_H__ #define __CONFIG_H__
#define PROJECT_NAME "${PROJECT_NAME}" #define PROJECT_NAME "${PROJECT_NAME}"
#define PROJECT_VERSION "${PROJECT_VERSION}" #define PROJECT_VERSION "${project_VERSION}"
#define PROJECT_ID "${project_ID}"
#define PROJECT_URL "${project_URL}" #define PROJECT_URL "${project_URL}"
#cmakedefine OPTION_NOINSTALL #if ${OPTION_NOINSTALL}
#ifdef OPTION_NOINSTALL
/* For developers. */ /* For developers. */
#define PROJECT_DOC_DIR "${CMAKE_SOURCE_DIR}/docs/"
#define PROJECT_SHARE_DIR "${CMAKE_SOURCE_DIR}/share/" #define PROJECT_SHARE_DIR "${CMAKE_SOURCE_DIR}/share/"
#define PROJECT_GSETTINGS_DIR "${CMAKE_BINARY_DIR}"
#elif defined (_WIN32) #elif defined (_WIN32)
#define PROJECT_DOC_DIR "share/doc/${PROJECT_NAME}/"
#define PROJECT_SHARE_DIR "share/${PROJECT_NAME}/" #define PROJECT_SHARE_DIR "share/${PROJECT_NAME}/"
#else #else
#define PROJECT_DOC_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}/"
#define PROJECT_SHARE_DIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/" #define PROJECT_SHARE_DIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/"
#endif #endif
#cmakedefine HAVE_SANE___RESTRICT
#cmakedefine HAVE_RESTRICT
#include <glib/gi18n.h> #include <glib/gi18n.h>
#define GETTEXT_DOMAIN "${PROJECT_NAME}" #define GETTEXT_DOMAIN "${PROJECT_NAME}"
@ -39,6 +36,14 @@
#endif #endif
#ifndef HAVE_SANE___RESTRICT
#ifdef HAVE_RESTRICT
#define __restrict restrict
#else
#define __restrict
#endif
#endif /* ! HAVE_SANE___RESTRICT */
/* We have to remove nodes first due to a bug in json-glib. */ /* We have to remove nodes first due to a bug in json-glib. */
#define json_object_set_member(object, name, node) \ #define json_object_set_member(object, name, node) \
G_STMT_START { \ G_STMT_START { \

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -1,7 +0,0 @@
body { max-width: 50em; margin: 0 auto 4em auto; padding: 0 2em;
font-family: sans-serif; } h1, h2, h3 { font-weight: normal; }
h1 { font-size: 2.5em; } h2 { font-size: 2em; } h3 { font-size: 1.33em; }
h2 { padding-top: .67em; border-top: 1px solid silver; }
p { line-height: 1.5; } .figure { text-align: center; } img { max-width: 100%; }
q { font-style: normal; } .details { border-bottom: 1px solid silver; }
.details br { display: none; } .details br + span:before { content: " — "; }

View File

@ -1,137 +0,0 @@
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="UTF-8">
<title>logdiag: Průvodce uživatele</title>
<link rel="stylesheet" href="stylesheet.css">
<style>
q:lang(cs):before { content: "„"; }
q:lang(cs):after { content: "“"; }
</style>
</head>
<body>
<h1>logdiag: Průvodce uživatele</h1>
<p class="details">
<span id="author">Přemysl Eric Janouch</span><br>
<span id="email"><a href="mailto:p@janouch.name">p@janouch.name</a></span><br>
<span id="revnumber">verze 0.3.0,</span>
<span id="revdate">2021-10-28</span>
<p class="figure"><img src="logdiag-cs.png" alt="Okno programu logdiag">
<h2>Úvod</h2>
<p>Tento dokument vás má za účel provést po aplikaci a pomoci vám se v ní
zorientovat. Popis úkonů se přednostně vztahuje na operační systém Microsoft
Windows, do jisté míry je však platný i pro jiné operační systémy.
<h2>Získání aplikace</h2>
<p>Nejnovější verzi aplikace je možné stáhnout na následující webové adrese:
<a href="https://git.janouch.name/p/logdiag">https://git.janouch.name/p/logdiag</a>.
<p class="figure"><img src="gitea.png" alt="Gitea">
<br>Obrázek 1: Nabídka pro stahování na stránkách projektu
<p>Až se ocitnete na webu, vyhledejte v záhlaví záložku s nápisem
<q>Releases</q> a klepněte na ni. Zobrazí se přehled vydání a pod hlavičkami
<q>Downloads</q> související soubory ke stažení. Instalační soubor pro Microsoft
Windows nese název ve stylu <q>logdiag-<i>verze</i>-Windows-x86.exe</q>.
<h2>Instalace</h2>
<p>Proces instalace je velmi přímočarý. Po úvodní obrazovce je vyžadován souhlas
s licencí. Pokud nerozumíte anglicky, její stručné shrnutí zní, že aplikaci
smíte v nezměněné formě zcela volně používat a redistribuovat, ale nejsou vám
poskytovány žádné záruky. Následuje výběr složky, do které chcete aplikaci
nainstalovat, a složky pro umístění ve Start menu. V případě, že nenastala žádná
náhlá chyba, už jen stačí potvrdit úspěšnou instalaci.
<p><b>Pozor</b>: Pokud aplikaci instalujete do složky, kde se nachází již
existující instalace, mohou nastat potíže. Ačkoliv je to možné, nepokoušejte se
z těch samých příčin instalovat ani více kopií vedle sebe. Nejdříve stávající
instalaci odstraňte, například pomocí zástupce umístěného ve Start menu.
<h2>Operace s objekty</h2>
<p>Každý diagram je tvořen z objektů, a s těmi se sdružují dále popsané operace.
Budete-li chtít momentálně prováděnou operaci zrušit, můžete tak obvykle učinit
stiskem klávesy Escape.
<!-- TODO: zkusit restrukturalizovat na:
Operace s objekty
Základní operace
Výběr
Přesun
Odstranění
Značky
Vložení
Otáčení
Spojení
Tvorba
-->
<h3>Výběr objektů</h3>
<p>Jednotlivé objekty můžete vybírat levým kliknutím myší. Ty se v reakci na to
vyznačí červenou barvou. Chcete-li vybrat objektů více, držte během klikání
stisknutou klávesu Shift.
<p class="figure" id="select-objects">
<img src="select-objects.png" alt="Výběr objektů">
<br>Obrázek 2: Výběr objektů v oblasti
<p>Alternativně můžete táhnout myší z volné oblasti diagramu do prostoru, viz
<a href="#select-objects">Obrázek 2</a>. Vyberou se objekty obsažené
ve vytvořeném obdélníku. Výběr lze zrušit klepnutím na prázdné místo.
<h3>Přesun objektů</h3>
<p>Přesun objektů se provede tažením objektů myší na požadované místo. Pokud
jsou tyto objekty součástí výběru, přesune se celý výběr. Ten lze též přesouvat
pomocí kurzorových kláves.
<h3>Odstranění objektů</h3>
<p>Objekty odstraníte stisknutím klávesy Delete, případně z menu aplikace.
<h3>Vložení značky</h3>
<p><i>Značky</i> představují nejdůležitější druh objektů. Do diagramu je vložíte
výběrem z nabídky značek umístěné po levé straně hlavního okna aplikace
a přetažením myší do diagramu na požadované umístění.
<h3>Otáčení značek</h3>
<p>Otočit značku vloženou do diagramu můžete přes pravé tlačítko myši.
<h3>Propojení terminálů</h3>
<p><i>Terminálem</i> se nazývá bod určený pro tvorbu spojení mezi značkami nebo
jinými spojeními. Abyste z něj spojení vyvedli, nejdříve na něj najeďte kurzorem
myši tak, aby se viditelně vyznačil kroužkem. Pak stiskněte levé tlačítko myši
a přetáhněte kurzor myši na místo, kde chcete, aby spojení končilo.
<p class="figure" id="create-connection">
<img src="create-connection-begin.png" alt="Začátek operace" align="center">
&nbsp;&#8230;&nbsp;
<img src="create-connection-end.png" alt="Konec operace" align="center">
<br>Obrázek 3: Propojení terminálů dvou značek
<h2>Časté problémy</h2>
<h3>Nelze otevřít uložený diagram</h3>
<p>Při ukládání se ujistěte, že zadaný název souboru obsahuje příponu
<q>.ldd</q>. V opačném případě se nezobrazí v dialogu pro otevření diagramu.
Pokud jste nějaký soubor již bez přípony uložili, napravíte to dodatečným
přidáním přípony k jeho názvu.
<h3>Schází mi popisky</h3>
<p>Tato funkcionalita zatím neexistuje, ale je možné tento nedostatek obejít
buď sejmutím snímku obrazovky klávesou PrintScreen a jeho vložením například
do aplikace Malování, nebo obdobně doplněním vašich textů do <q>vytištěného</q>
PDF souboru.
<script>
var toc = '', all = document.querySelectorAll('h2')
for (var i = 0; i < all.length; i++) {
var name = all[i].innerHTML.replace(/[^0-9a-z]/ig, '-')
toc += '<li><p><a href="#' + name + '">' + all[i].innerHTML + '</a></li>'
all[i].id = name
all[i].innerHTML = (i + 1) + '. ' + all[i].innerHTML
}
all[0].insertAdjacentHTML('beforebegin',
'<h2>Obsah</h2><ol>' + toc + '</ol>')
</script>

View File

@ -1,129 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>logdiag: User Guide</title>
<link rel="stylesheet" href="stylesheet.css">
<style>
q:lang(en):before { content: ""; }
q:lang(en):after { content: ""; }
</style>
</head>
<body>
<h1>logdiag: User Guide</h1>
<p class="details">
<span id="author">Přemysl Eric Janouch</span><br>
<span id="email"><a href="mailto:p@janouch.name">p@janouch.name</a></span><br>
<span id="revnumber">version 0.3.0,</span>
<span id="revdate">2021-10-28</span>
<p class="figure"><img src="logdiag-en.png" alt="logdiag program window">
<h2>Introduction</h2>
<p>This document will guide you through the application and help to familiarize
you with it. The description of tasks mainly targets the Microsoft Windows
operating system, though its also valid for other operating systems to
a certain extent.
<h2>Getting the application</h2>
<p>Download the newest version of the application at the following web address:
<a href="https://git.janouch.name/p/logdiag">https://git.janouch.name/p/logdiag</a>.
<p class="figure"><img src="gitea.png" alt="Gitea">
<br>Figure 1: The download menu on the project site
<p>While on the web, look for a tab entitled <q>Releases</q> and click on it.
A list of versions will appear with files for download listed under
<q>Downloads</q> headings. The installation file for Microsoft Windows is named
in the style of <q>logdiag-<i>version</i>-Windows-x86.exe</q>.
<h2>Installation</h2>
<p>The installation process is quite straight-forward. After the initial screen
a license agreement is required. Next, choose a folder in which to install
the application and another one for placement in the Start menu. So long as
no unexpected errors have occurred, all thats left is confirming a successful
installation.
<p><b>Warning</b>: If the application is installed into a folder where
a previous installation is already located, problems may arise. Although it is
possible to do so, dont try to install multiple copies parallely either, for
the same reasons. Remove the current installation first, for example by using
the shortcut located in the Start menu.
<h2>Operations with objects</h2>
<p>Each diagram consists of objects, and these are accompanied by the operations
described below. To cancel any current operation, press the Escape key.
<!-- TODO: see the Czech version -->
<h3>Selecting objects</h3>
<p>Select single objects by left-clicking on them. They will get highlighted
with red color in reaction to this. To select multiple objects, hold the Shift
key while clicking.
<p class="figure" id="select-objects">
<img src="select-objects.png" alt="select objects">
<br>Figure 2: Selecting objects inside an area
<p>Alternatively drag the mouse from free space within the diagram into
the area, see <a href="#select-objects">Figure 2</a>. Objects contained in this
rectangle will be selected. The selection may later be dismissed by just
clicking into free space.
<h3>Moving objects</h3>
<p>Moving of objects is done by dragging them with the mouse onto the desired
place. If these objects form a part of the current selection, the whole
selection is moved. The selection may also be moved using cursor keys.
<h3>Removing objects</h3>
<p>Remove objects either by pressing the Delete key or from the application
menu.
<h3>Inserting symbols</h3>
<p><i>Symbols</i> constitute the most important kind of objects. Insert them
into the diagram by choosing one from the symbol menu located on the left side
of the main application window and dragging it onto the diagram where you want
the symbol to be placed.
<h3>Rotating symbols</h3>
<p>Rotate a symbol inserted into the diagram by right-clicking on it.
<h3>Connecting terminals</h3>
<p>A point intended for creation of connections between symbols or other
connections is called a <i>terminal</i>. To lead a connection out of it, first
hover it with the mouse pointer, so it gets visibly highlighted with a circle.
Then press the left mouse button and drag the pointer onto the place where you
want the connection to end.
<p class="figure" id="create-connection">
<img src="create-connection-begin.png" alt="Start of operation" align="center">
&nbsp;&#8230;&nbsp;
<img src="create-connection-end.png" alt="End of operation" align="center">
<br>Figure 3: Interconnecting terminals of two symbols
<h2>Frequent problems</h2>
<h3>Cant open a saved diagram</h3>
<p>When saving, ensure that the filename youve typed in contains the
<q>.ldd</q> suffix. If not, it wont show up in the dialog for opening diagrams.
In case youve already saved a file without an extension, you may fix this
situation by adding the suffix to its name.
<h3>I miss labels</h3>
<p>This functionality doesn't exist yet, but it is possible to get around this
limitation either by using the PrintScreen key to capture a screenshot
and inserting it to, for example, Paint, or similarly by adding your texts
to a <q>printed</q> PDF file.
<script>
var toc = '', all = document.querySelectorAll('h2')
for (var i = 0; i < all.length; i++) {
var name = all[i].innerHTML.replace(/[^0-9a-z]/ig, '-')
toc += '<li><p><a href="#' + name + '">' + all[i].innerHTML + '</a></li>'
all[i].id = name
all[i].innerHTML = (i + 1) + '. ' + all[i].innerHTML
}
all[0].insertAdjacentHTML('beforebegin',
'<h2>Table of Contents</h2><ol>' + toc + '</ol>')
</script>

View File

@ -1,630 +0,0 @@
/*
* ld-category-symbol-view.c
*
* This file is a part of logdiag.
* Copyright 2012, 2015 Přemysl Eric Janouch
*
* See the file LICENSE for licensing information.
*
*/
#include "liblogdiag.h"
#include "config.h"
/**
* SECTION:ld-category-symbol-view
* @short_description: A widget that displays symbols in a category
* @see_also: #LdCategory, #LdDiagramView
*
* #LdCategorySymbolView allows the user to drag symbols from an #LdCategory
* onto #LdDiagramView.
*/
/* Milimetres per inch. */
#define MM_PER_INCH 25.4
/* The default screen resolution in DPI units. */
#define DEFAULT_SCREEN_RESOLUTION 96
#define SYMBOL_WIDTH 50 /* Width of a symbol. */
#define SYMBOL_HEIGHT 40 /* Height of a symbol. */
#define SYMBOL_SPACING 10 /* Spacing between symbols, and also borders. */
typedef struct
{
LdSymbol *symbol; /* The associated symbol, ref'ed. */
gchar *path; /* Path to the symbol. */
GdkRectangle rect; /* Clipping rectangle. */
gdouble scale; /* Scale to draw the symbol in. */
gdouble dx, dy; /* Delta into .rect. */
}
SymbolData;
/*
* LdCategorySymbolViewPrivate:
* @category: a category object assigned as a model.
* @path: path to the category within the library.
* @layout: (element-type SymbolData *): current layout of symbols.
* @preselected: currently preselected symbol.
* @dragged: currently dragged symbol.
*/
struct _LdCategorySymbolViewPrivate
{
LdCategory *category;
gchar *path;
GSList *layout;
SymbolData *preselected;
SymbolData *dragged;
};
enum
{
PROP_0,
PROP_CATEGORY
};
static void ld_category_symbol_view_get_property (GObject *object,
guint property_id, GValue *value, GParamSpec *pspec);
static void ld_category_symbol_view_set_property (GObject *object,
guint property_id, const GValue *value, GParamSpec *pspec);
static void ld_category_symbol_view_finalize (GObject *gobject);
static void on_size_allocate (GtkWidget *widget, GdkRectangle *allocation);
static gboolean on_draw (GtkWidget *widget, cairo_t *cr);
static GtkSizeRequestMode on_get_request_mode (GtkWidget *widget);
static void on_get_preferred_height (GtkWidget *widget,
gint *minimum_height, gint *natural_height);
static void on_get_preferred_width_for_height (GtkWidget *widget,
gint height, gint *minimum_width, gint *natural_width);
static void on_get_preferred_width (GtkWidget *widget,
gint *minimum_width, gint *natural_width);
static void on_get_preferred_height_for_width (GtkWidget *widget,
gint width, gint *minimum_height, gint *natural_height);
static void ld_category_symbol_view_set_category
(LdCategoryView *iface, LdCategory *category);
static LdCategory *ld_category_symbol_view_get_category
(LdCategoryView *iface);
static void
ld_category_view_init (LdCategoryViewInterface *iface)
{
iface->set_category = ld_category_symbol_view_set_category;
iface->get_category = ld_category_symbol_view_get_category;
}
G_DEFINE_TYPE_WITH_CODE (LdCategorySymbolView,
ld_category_symbol_view, GTK_TYPE_DRAWING_AREA,
G_IMPLEMENT_INTERFACE (LD_TYPE_CATEGORY_VIEW, ld_category_view_init))
static void
ld_category_symbol_view_class_init (LdCategorySymbolViewClass *klass)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = G_OBJECT_CLASS (klass);
object_class->get_property = ld_category_symbol_view_get_property;
object_class->set_property = ld_category_symbol_view_set_property;
object_class->finalize = ld_category_symbol_view_finalize;
widget_class = GTK_WIDGET_CLASS (klass);
widget_class->draw = on_draw;
widget_class->get_request_mode = on_get_request_mode;
widget_class->get_preferred_width = on_get_preferred_width;
widget_class->get_preferred_width_for_height
= on_get_preferred_width_for_height;
widget_class->get_preferred_height = on_get_preferred_height;
widget_class->get_preferred_height_for_width
= on_get_preferred_height_for_width;
g_object_class_override_property (object_class, PROP_CATEGORY, "category");
g_type_class_add_private (klass, sizeof (LdCategorySymbolViewPrivate));
}
static void
symbol_redraw (LdCategorySymbolView *self, SymbolData *symbol)
{
gtk_widget_queue_draw_area (GTK_WIDGET (self),
symbol->rect.x,
symbol->rect.y,
symbol->rect.width,
symbol->rect.height);
}
static void
symbol_deselect (LdCategorySymbolView *self)
{
SymbolData *preselected;
preselected = self->priv->preselected;
if (!preselected)
return;
g_signal_emit (self, LD_CATEGORY_VIEW_GET_INTERFACE (self)->
symbol_deselected_signal, 0, preselected->symbol, preselected->path);
symbol_redraw (self, preselected);
self->priv->preselected = NULL;
gtk_drag_source_unset (GTK_WIDGET (self));
}
static void
symbol_data_free (SymbolData *self)
{
g_object_unref (self->symbol);
g_free (self->path);
g_slice_free (SymbolData, self);
}
typedef struct
{
guint total_height; /* Total height required to show the symbols. */
guint max_width; /* Width available to the widget. */
GSList *cur_row; /* Current row of symbols. */
guint cur_width; /* Current width of the row. */
guint cur_height_up; /* Current max. upper height of symbols. */
guint cur_height_down; /* Current max. lower height of symbols. */
}
LayoutContext;
static void
layout_destroy (LdCategorySymbolView *self)
{
symbol_deselect (self);
g_slist_foreach (self->priv->layout, (GFunc) symbol_data_free, NULL);
g_slist_free (self->priv->layout);
self->priv->layout = NULL;
self->priv->preselected = NULL;
self->priv->dragged = NULL;
}
static GSList *
layout_finish_row (LayoutContext *ctx)
{
GSList *item, *result;
gint row_height, h_delta;
row_height = SYMBOL_SPACING + ctx->cur_height_up + ctx->cur_height_down;
h_delta = (ctx->max_width - ctx->cur_width) / 2;
for (item = ctx->cur_row; item; item = item->next)
{
SymbolData *data;
data = item->data;
data->rect.x += h_delta;
data->rect.height = row_height;
data->dy = SYMBOL_SPACING * 0.5 + ctx->cur_height_up;
}
result = g_slist_reverse (ctx->cur_row);
ctx->cur_row = NULL;
ctx->total_height += row_height;
ctx->cur_width = SYMBOL_SPACING;
ctx->cur_height_up = 0;
ctx->cur_height_down = 0;
return result;
}
static gint
layout_for_width (LdCategorySymbolView *self, gint width)
{
GSList *symbols, *iter;
LayoutContext ctx = {SYMBOL_SPACING, 0, NULL, SYMBOL_SPACING, 0, 0};
layout_destroy (self);
ctx.max_width = width;
symbols = (GSList *) ld_category_get_symbols (self->priv->category);
for (iter = symbols; iter; iter = iter->next)
{
SymbolData *data;
LdRectangle area;
LdSymbol *symbol;
gint real_width, height_up, height_down;
symbol = LD_SYMBOL (iter->data);
ld_symbol_get_area (symbol, &area);
data = g_slice_new (SymbolData);
data->symbol = g_object_ref (symbol);
data->path = g_build_path (LD_LIBRARY_IDENTIFIER_SEPARATOR,
self->priv->path, ld_symbol_get_name (symbol), NULL);
/* Compute the scale to fit the symbol to an area of
* SYMBOL_WIDTH * SYMBOL_HEIGHT, vertically centred. */
data->scale = SYMBOL_HEIGHT * 0.5
/ MAX (ABS (area.y), ABS (area.y + area.height)) * 0.5;
if (data->scale * area.width > SYMBOL_WIDTH)
data->scale = SYMBOL_WIDTH / area.width;
real_width = data->scale * area.width + 0.5;
data->rect.width = real_width + SYMBOL_SPACING;
/* Now I have no idea what this does but it worked before.
* When I do, I have to write it in here. */
data->dx = data->rect.width * 0.5 + data->scale
* (area.width * 0.5 - ABS (area.x + area.width));
if (ctx.cur_width + real_width + SYMBOL_SPACING > ctx.max_width
&& ctx.cur_row != NULL)
{
self->priv->layout = g_slist_concat (self->priv->layout,
layout_finish_row (&ctx));
}
/* Half of the spacing is included on each side of the rect. */
data->rect.x = ctx.cur_width - SYMBOL_SPACING / 2;
data->rect.y = ctx.total_height - SYMBOL_SPACING / 2;
height_up = data->scale * ABS (area.y);
height_down = data->scale * ABS (area.y + area.height);
if (height_up > ctx.cur_height_up)
ctx.cur_height_up = height_up;
if (height_down > ctx.cur_height_down)
ctx.cur_height_down = height_down;
ctx.cur_row = g_slist_prepend (ctx.cur_row, data);
ctx.cur_width += real_width + SYMBOL_SPACING;
}
if (ctx.cur_row != NULL)
self->priv->layout = g_slist_concat (self->priv->layout,
layout_finish_row (&ctx));
return ctx.total_height;
}
static GtkSizeRequestMode
on_get_request_mode (GtkWidget *widget)
{
return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
}
static void
on_get_preferred_height (GtkWidget *widget,
gint *minimum_height, gint *natural_height)
{
LdCategorySymbolView *self = LD_CATEGORY_SYMBOL_VIEW (widget);
if (!self->priv->category
|| !ld_category_get_symbols (self->priv->category))
*minimum_height = *natural_height = 0;
else
*minimum_height = *natural_height = SYMBOL_HEIGHT + 2 * SYMBOL_SPACING;
}
static void
on_get_preferred_width_for_height (GtkWidget *widget,
gint height, gint *minimum_width, gint *natural_width)
{
// TODO: compute it the other way around
on_get_preferred_width (widget, minimum_width, natural_width);
}
static void
on_get_preferred_width (GtkWidget *widget,
gint *minimum_width, gint *natural_width)
{
LdCategorySymbolView *self = LD_CATEGORY_SYMBOL_VIEW (widget);
if (!self->priv->category
|| !ld_category_get_symbols (self->priv->category))
*minimum_width = *natural_width = 0;
else
*minimum_width = *natural_width = SYMBOL_WIDTH + 2 * SYMBOL_SPACING;
}
static void
on_get_preferred_height_for_width (GtkWidget *widget,
gint width, gint *minimum_height, gint *natural_height)
{
LdCategorySymbolView *self = LD_CATEGORY_SYMBOL_VIEW (widget);
*minimum_height = *natural_height = layout_for_width (self, width);
}
static void
on_size_allocate (GtkWidget *widget, GdkRectangle *allocation)
{
LdCategorySymbolView *self = LD_CATEGORY_SYMBOL_VIEW (widget);
layout_for_width (self, allocation->width);
}
static gboolean
on_draw (GtkWidget *widget, cairo_t *cr)
{
LdCategorySymbolView *self;
GSList *iter;
GdkRGBA color;
GtkStyleContext *context;
self = LD_CATEGORY_SYMBOL_VIEW (widget);
GdkRectangle draw_area;
if (!gdk_cairo_get_clip_rectangle (cr, &draw_area))
return FALSE;
context = gtk_widget_get_style_context (widget);
// XXX: alternatively, we could use gtk_style_context_lookup_color()
// with hardcoded colour names ("theme_*_color")--this is cleaner,
// and unlike GtkStyle doesn't cause deprecation warnings
gtk_style_context_add_class (context, "gtkstyle-fallback");
gtk_style_context_get_background_color (context,
GTK_STATE_FLAG_NORMAL, &color);
gdk_cairo_set_source_rgba (cr, &color);
cairo_paint (cr);
for (iter = self->priv->layout; iter; iter = iter->next)
{
SymbolData *data;
data = iter->data;
if (!gdk_rectangle_intersect (&data->rect, &draw_area, NULL))
continue;
cairo_save (cr);
gdk_cairo_rectangle (cr, &data->rect);
cairo_clip (cr);
GtkStateFlags state = GTK_STATE_FLAG_NORMAL;
if (data == self->priv->preselected)
state = GTK_STATE_FLAG_SELECTED;
gtk_style_context_get_background_color (context, state, &color);
gdk_cairo_set_source_rgba (cr, &color);
cairo_paint (cr);
gtk_style_context_get_color (context, state, &color);
gdk_cairo_set_source_rgba (cr, &color);
cairo_translate (cr, data->rect.x + data->dx, data->rect.y + data->dy);
cairo_scale (cr, data->scale, data->scale);
cairo_set_line_width (cr, 1 / data->scale);
ld_symbol_draw (data->symbol, cr);
cairo_restore (cr);
}
return FALSE;
}
static gboolean
on_motion_notify (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
{
LdCategorySymbolView *self;
GSList *iter;
if (event->state & GDK_BUTTON1_MASK)
return FALSE;
self = LD_CATEGORY_SYMBOL_VIEW (widget);
for (iter = self->priv->layout; iter; iter = iter->next)
{
SymbolData *data;
data = iter->data;
if (event->x < data->rect.x
|| event->y < data->rect.y
|| event->x >= data->rect.x + data->rect.width
|| event->y >= data->rect.y + data->rect.height)
continue;
if (data != self->priv->preselected)
{
GtkTargetEntry target = {"ld-symbol", GTK_TARGET_SAME_APP, 0};
symbol_deselect (self);
self->priv->preselected = data;
symbol_redraw (self, data);
gtk_drag_source_set (widget,
GDK_BUTTON1_MASK, &target, 1, GDK_ACTION_COPY);
g_signal_emit (self, LD_CATEGORY_VIEW_GET_INTERFACE (self)->
symbol_selected_signal, 0, data->symbol, data->path);
}
return FALSE;
}
symbol_deselect (self);
return FALSE;
}
static gboolean
on_leave_notify (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
{
switch (event->mode)
{
case GDK_CROSSING_GRAB:
case GDK_CROSSING_GTK_GRAB:
case GDK_CROSSING_STATE_CHANGED:
break;
default:
symbol_deselect (LD_CATEGORY_SYMBOL_VIEW (widget));
}
return FALSE;
}
static void
on_drag_data_get (GtkWidget *widget, GdkDragContext *ctx,
GtkSelectionData *selection_data, guint target_type, guint time,
gpointer user_data)
{
LdCategorySymbolView *self;
self = LD_CATEGORY_SYMBOL_VIEW (widget);
g_return_if_fail (self->priv->dragged != NULL);
gtk_selection_data_set (selection_data,
gtk_selection_data_get_target (selection_data),
8, (guchar *) self->priv->dragged->path,
strlen (self->priv->dragged->path));
}
static void
on_drag_begin (GtkWidget *widget, GdkDragContext *ctx, gpointer user_data)
{
LdCategorySymbolView *self;
GdkPixbuf *pbuf;
self = LD_CATEGORY_SYMBOL_VIEW (widget);
g_return_if_fail (self->priv->preselected != NULL);
/* Working around a mysterious bug where we /sometimes/ get deselected. */
self->priv->dragged = self->priv->preselected;
/* Some of the larger previews didn't work, and we have to get rid of
* the icon later when we're hovering above LdDiagramView anyway. */
pbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
gdk_pixbuf_fill (pbuf, 0x00000000);
gtk_drag_set_icon_pixbuf (ctx, pbuf, 0, 0);
g_object_unref (pbuf);
}
static void
on_drag_end (GtkWidget *widget, GdkDragContext *ctx, gpointer user_data)
{
LdCategorySymbolView *self;
self = LD_CATEGORY_SYMBOL_VIEW (widget);
symbol_deselect (self);
self->priv->dragged = NULL;
}
static void
ld_category_symbol_view_init (LdCategorySymbolView *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE
(self, LD_TYPE_CATEGORY_SYMBOL_VIEW, LdCategorySymbolViewPrivate);
g_signal_connect (self, "size-allocate",
G_CALLBACK (on_size_allocate), NULL);
g_signal_connect (self, "motion-notify-event",
G_CALLBACK (on_motion_notify), NULL);
g_signal_connect (self, "leave-notify-event",
G_CALLBACK (on_leave_notify), NULL);
g_signal_connect (self, "drag-begin",
G_CALLBACK (on_drag_begin), NULL);
g_signal_connect (self, "drag-data-get",
G_CALLBACK (on_drag_data_get), NULL);
g_signal_connect (self, "drag-end",
G_CALLBACK (on_drag_end), NULL);
gtk_widget_add_events (GTK_WIDGET (self),
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
| GDK_LEAVE_NOTIFY_MASK);
}
static void
ld_category_symbol_view_finalize (GObject *gobject)
{
LdCategorySymbolView *self;
self = LD_CATEGORY_SYMBOL_VIEW (gobject);
layout_destroy (self);
if (self->priv->category)
g_object_unref (self->priv->category);
g_free (self->priv->path);
/* Chain up to the parent class. */
G_OBJECT_CLASS (ld_category_symbol_view_parent_class)->finalize (gobject);
}
static void
ld_category_symbol_view_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec)
{
switch (property_id)
{
case PROP_CATEGORY:
g_value_set_object (value,
ld_category_view_get_category (LD_CATEGORY_VIEW (object)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
ld_category_symbol_view_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec)
{
switch (property_id)
{
case PROP_CATEGORY:
ld_category_view_set_category (LD_CATEGORY_VIEW (object),
LD_CATEGORY (g_value_get_object (value)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
/* ===== Interface ========================================================= */
/**
* ld_category_symbol_view_new:
* @category: (allow-none): a category to be assigned to the widget.
*
* Create an instance.
*/
GtkWidget *
ld_category_symbol_view_new (LdCategory *category)
{
LdCategorySymbolView *self;
self = g_object_new (LD_TYPE_CATEGORY_SYMBOL_VIEW, NULL);
ld_category_view_set_category (LD_CATEGORY_VIEW (self), category);
return GTK_WIDGET (self);
}
static void
ld_category_symbol_view_set_category (LdCategoryView *iface,
LdCategory *category)
{
LdCategorySymbolView *self;
g_return_if_fail (LD_IS_CATEGORY_SYMBOL_VIEW (iface));
g_return_if_fail (LD_IS_CATEGORY (category));
self = LD_CATEGORY_SYMBOL_VIEW (iface);
if (self->priv->category)
{
g_object_unref (self->priv->category);
g_free (self->priv->path);
self->priv->path = NULL;
}
/* XXX: We should rebuild the path if the name changes but it shouldn't
* happen and we would have to track the parents, too. */
self->priv->path = ld_category_get_path (category);
self->priv->category = category;
g_object_ref (category);
g_object_notify (G_OBJECT (self), "category");
gtk_widget_queue_resize (GTK_WIDGET (self));
}
static LdCategory *
ld_category_symbol_view_get_category (LdCategoryView *iface)
{
g_return_val_if_fail (LD_IS_CATEGORY_SYMBOL_VIEW (iface), NULL);
return LD_CATEGORY_SYMBOL_VIEW (iface)->priv->category;
}

View File

@ -1,64 +0,0 @@
/*
* ld-category-symbol-view.h
*
* This file is a part of logdiag.
* Copyright 2012 Přemysl Eric Janouch
*
* See the file LICENSE for licensing information.
*
*/
#ifndef __LD_CATEGORY_SYMBOL_VIEW_H__
#define __LD_CATEGORY_SYMBOL_VIEW_H__
G_BEGIN_DECLS
#define LD_TYPE_CATEGORY_SYMBOL_VIEW (ld_category_symbol_view_get_type ())
#define LD_CATEGORY_SYMBOL_VIEW(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
LD_TYPE_CATEGORY_SYMBOL_VIEW, \
LdCategorySymbolView))
#define LD_CATEGORY_SYMBOL_VIEW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
LD_TYPE_CATEGORY_SYMBOL_VIEW, \
LdCategorySymbolViewClass))
#define LD_IS_CATEGORY_SYMBOL_VIEW(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_CATEGORY_SYMBOL_VIEW))
#define LD_IS_CATEGORY_SYMBOL_VIEW_CLASS(klass) \
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_CATEGORY_SYMBOL_VIEW))
#define LD_CATEGORY_SYMBOL_VIEW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
LD_CATEGORY_SYMBOL_VIEW, \
LdCategorySymbolViewClass))
typedef struct _LdCategorySymbolView LdCategorySymbolView;
typedef struct _LdCategorySymbolViewPrivate LdCategorySymbolViewPrivate;
typedef struct _LdCategorySymbolViewClass LdCategorySymbolViewClass;
/**
* LdCategorySymbolView:
*/
struct _LdCategorySymbolView
{
/*< private >*/
GtkDrawingArea parent_instance;
LdCategorySymbolViewPrivate *priv;
};
struct _LdCategorySymbolViewClass
{
/*< private >*/
GtkDrawingAreaClass parent_class;
};
GType ld_category_symbol_view_get_type (void) G_GNUC_CONST;
GtkWidget *ld_category_symbol_view_new (LdCategory *category);
G_END_DECLS
#endif /* ! __LD_CATEGORY_SYMBOL_VIEW_H__ */

View File

@ -1,342 +0,0 @@
/*
* ld-category-tree-view.c
*
* This file is a part of logdiag.
* Copyright 2011, 2012 Přemysl Eric Janouch
*
* See the file LICENSE for licensing information.
*
*/
#include "liblogdiag.h"
#include "config.h"
/**
* SECTION:ld-category-tree-view
* @short_description: A category tree view widget
* @see_also: #LdCategory
*
* #LdCategoryTreeView enables the user to drag symbols from #LdLibrary
* onto #LdDiagramView.
*/
/*
* LdCategoryTreeViewPrivate:
* @category: a category object assigned as a model.
* @expander_prefix: a string to prepend to subcategory labels in expanders.
*/
struct _LdCategoryTreeViewPrivate
{
LdCategory *category;
gchar *expander_prefix;
};
enum
{
PROP_0,
PROP_CATEGORY
};
static void ld_category_tree_view_get_property (GObject *object,
guint property_id, GValue *value, GParamSpec *pspec);
static void ld_category_tree_view_set_property (GObject *object,
guint property_id, const GValue *value, GParamSpec *pspec);
static void ld_category_tree_view_dispose (GObject *gobject);
static void ld_category_tree_view_set_category (LdCategoryView *iface,
LdCategory *category);
static LdCategory *ld_category_tree_view_get_category (LdCategoryView *iface);
static void
ld_category_view_init (LdCategoryViewInterface *iface)
{
iface->set_category = ld_category_tree_view_set_category;
iface->get_category = ld_category_tree_view_get_category;
}
G_DEFINE_TYPE_WITH_CODE (LdCategoryTreeView,
ld_category_tree_view, GTK_TYPE_BOX,
G_IMPLEMENT_INTERFACE (LD_TYPE_CATEGORY_VIEW, ld_category_view_init))
static void
ld_category_tree_view_class_init (LdCategoryTreeViewClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
object_class->get_property = ld_category_tree_view_get_property;
object_class->set_property = ld_category_tree_view_set_property;
object_class->dispose = ld_category_tree_view_dispose;
g_object_class_override_property (object_class, PROP_CATEGORY, "category");
g_type_class_add_private (klass, sizeof (LdCategoryTreeViewPrivate));
}
static void
ld_category_tree_view_init (LdCategoryTreeView *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE
(self, LD_TYPE_CATEGORY_TREE_VIEW, LdCategoryTreeViewPrivate);
gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
}
static void
ld_category_tree_view_dispose (GObject *gobject)
{
LdCategoryTreeView *self;
self = LD_CATEGORY_TREE_VIEW (gobject);
ld_category_view_set_category (LD_CATEGORY_VIEW (self), NULL);
g_free (self->priv->expander_prefix);
self->priv->expander_prefix = NULL;
/* Chain up to the parent class. */
G_OBJECT_CLASS (ld_category_tree_view_parent_class)->dispose (gobject);
}
static void
ld_category_tree_view_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec)
{
switch (property_id)
{
case PROP_CATEGORY:
g_value_set_object (value,
ld_category_view_get_category (LD_CATEGORY_VIEW (object)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
ld_category_tree_view_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec)
{
switch (property_id)
{
case PROP_CATEGORY:
ld_category_view_set_category (LD_CATEGORY_VIEW (object),
LD_CATEGORY (g_value_get_object (value)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static GtkWidget *
create_empty_label (void)
{
GtkWidget *label;
PangoAttrList *attr;
label = gtk_label_new (_("Empty"));
gtk_widget_set_sensitive (label, FALSE);
gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
gtk_widget_set_margin_left (label, 5);
gtk_widget_set_margin_right (label, 5);
gtk_widget_set_margin_top (label, 5);
gtk_widget_set_margin_bottom (label, 5);
attr = pango_attr_list_new ();
pango_attr_list_change (attr, pango_attr_style_new (PANGO_STYLE_ITALIC));
gtk_label_set_attributes (GTK_LABEL (label), attr);
pango_attr_list_unref (attr);
return label;
}
static void
reconstruct_prefix (LdCategoryTreeView *self)
{
LdCategory *iter;
gchar *start, *end;
start = g_strdup ("");
end = g_strdup ("");
for (iter = self->priv->category; iter;
iter = ld_category_get_parent (iter))
{
const gchar *name;
gchar *new_start, *new_end, *name_escaped;
/* Stop at the root category. */
if (!strcmp (ld_category_get_name (iter),
LD_LIBRARY_IDENTIFIER_SEPARATOR))
break;
name = ld_category_get_human_name (iter);
name_escaped = g_markup_escape_text (name, -1);
new_start = g_strconcat (start, "<small>", NULL);
new_end = g_strconcat (name_escaped, ":</small> ", end, NULL);
g_free (name_escaped);
g_free (start);
g_free (end);
start = new_start;
end = new_end;
}
g_free (self->priv->expander_prefix);
self->priv->expander_prefix = g_strconcat (start, end, NULL);
g_free (start);
g_free (end);
}
static void
on_symbol_selected (GObject *source,
LdSymbol *symbol, const gchar *path, LdCategoryTreeView *self)
{
g_signal_emit (self, LD_CATEGORY_VIEW_GET_INTERFACE (self)->
symbol_selected_signal, 0, symbol, path);
}
static void
on_symbol_deselected (GObject *source,
LdSymbol *symbol, const gchar *path, LdCategoryTreeView *self)
{
g_signal_emit (self, LD_CATEGORY_VIEW_GET_INTERFACE (self)->
symbol_deselected_signal, 0, symbol, path);
}
static void
load_category_cb (gpointer data, gpointer user_data)
{
LdCategoryTreeView *self;
LdCategory *cat;
GtkWidget *expander, *child;
gchar *name, *label_markup;
g_return_if_fail (LD_IS_CATEGORY_TREE_VIEW (user_data));
g_return_if_fail (LD_IS_CATEGORY (data));
self = user_data;
cat = data;
name = g_markup_escape_text (ld_category_get_human_name (cat), -1);
label_markup = g_strconcat (self->priv->expander_prefix, name, NULL);
g_free (name);
expander = gtk_expander_new (label_markup);
gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
gtk_expander_set_use_markup (GTK_EXPANDER (expander), TRUE);
g_free (label_markup);
child = ld_category_tree_view_new (cat);
gtk_container_add (GTK_CONTAINER (expander), child);
gtk_box_pack_start (GTK_BOX (self), expander, FALSE, FALSE, 0);
g_signal_connect_after (child, "symbol-selected",
G_CALLBACK (on_symbol_selected), self);
g_signal_connect_after (child, "symbol-deselected",
G_CALLBACK (on_symbol_deselected), self);
}
static void
reload_category (LdCategoryTreeView *self)
{
g_return_if_fail (LD_IS_CATEGORY_TREE_VIEW (self));
/* Clear the container first, if there is already something in it. */
gtk_container_foreach (GTK_CONTAINER (self),
(GtkCallback) gtk_widget_destroy, NULL);
/* XXX: We might want to disconnect signal handlers. */
if (self->priv->category)
{
GSList *symbols, *children;
symbols = (GSList *) ld_category_get_symbols (self->priv->category);
children = (GSList *) ld_category_get_children (self->priv->category);
if (symbols)
{
GtkWidget *symbol_view;
symbol_view = ld_category_symbol_view_new (self->priv->category);
gtk_box_pack_start (GTK_BOX (self), symbol_view, FALSE, FALSE, 0);
g_signal_connect_after (symbol_view, "symbol-selected",
G_CALLBACK (on_symbol_selected), self);
g_signal_connect_after (symbol_view, "symbol-deselected",
G_CALLBACK (on_symbol_deselected), self);
}
if (children)
{
reconstruct_prefix (self);
g_slist_foreach (children, load_category_cb, self);
}
else if (!symbols)
gtk_box_pack_start (GTK_BOX (self),
create_empty_label (), FALSE, FALSE, 0);
}
}
/* ===== Interface ========================================================= */
/**
* ld_category_tree_view_new:
* @category: (allow-none): a category to be assigned to the widget.
*
* Create an instance.
*/
GtkWidget *
ld_category_tree_view_new (LdCategory *category)
{
LdCategoryTreeView *self;
self = g_object_new (LD_TYPE_CATEGORY_TREE_VIEW, NULL);
ld_category_view_set_category (LD_CATEGORY_VIEW (self), category);
return GTK_WIDGET (self);
}
static void
ld_category_tree_view_set_category (LdCategoryView *iface, LdCategory *category)
{
LdCategoryTreeView *self;
g_return_if_fail (LD_IS_CATEGORY_TREE_VIEW (iface));
g_return_if_fail (LD_IS_CATEGORY (category) || category == NULL);
self = LD_CATEGORY_TREE_VIEW (iface);
if (self->priv->category)
{
g_signal_handlers_disconnect_by_func (self->priv->category,
reload_category, self);
g_object_unref (self->priv->category);
}
self->priv->category = category;
if (category)
{
g_signal_connect_data (category, "children-changed",
G_CALLBACK (reload_category), self,
NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_signal_connect_data (category, "notify::parent",
G_CALLBACK (reload_category), self,
NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_object_ref (category);
}
reload_category (self);
g_object_notify (G_OBJECT (self), "category");
}
static LdCategory *
ld_category_tree_view_get_category (LdCategoryView *iface)
{
g_return_val_if_fail (LD_IS_CATEGORY_TREE_VIEW (iface), NULL);
return LD_CATEGORY_TREE_VIEW (iface)->priv->category;
}

View File

@ -1,64 +0,0 @@
/*
* ld-category-tree-view.h
*
* This file is a part of logdiag.
* Copyright 2011, 2012 Přemysl Eric Janouch
*
* See the file LICENSE for licensing information.
*
*/
#ifndef __LD_CATEGORY_TREE_VIEW_H__
#define __LD_CATEGORY_TREE_VIEW_H__
G_BEGIN_DECLS
#define LD_TYPE_CATEGORY_TREE_VIEW (ld_category_tree_view_get_type ())
#define LD_CATEGORY_TREE_VIEW(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
LD_TYPE_CATEGORY_TREE_VIEW, \
LdCategoryTreeView))
#define LD_CATEGORY_TREE_VIEW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
LD_TYPE_CATEGORY_TREE_VIEW, \
LdCategoryTreeViewClass))
#define LD_IS_CATEGORY_TREE_VIEW(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_CATEGORY_TREE_VIEW))
#define LD_IS_CATEGORY_TREE_VIEW_CLASS(klass) \
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_CATEGORY_TREE_VIEW))
#define LD_CATEGORY_TREE_VIEW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
LD_CATEGORY_TREE_VIEW, \
LdCategoryTreeViewClass))
typedef struct _LdCategoryTreeView LdCategoryTreeView;
typedef struct _LdCategoryTreeViewPrivate LdCategoryTreeViewPrivate;
typedef struct _LdCategoryTreeViewClass LdCategoryTreeViewClass;
/**
* LdCategoryTreeView:
*/
struct _LdCategoryTreeView
{
/*< private >*/
GtkBox parent_instance;
LdCategoryTreeViewPrivate *priv;
};
struct _LdCategoryTreeViewClass
{
/*< private >*/
GtkBoxClass parent_class;
};
GType ld_category_tree_view_get_type (void) G_GNUC_CONST;
GtkWidget *ld_category_tree_view_new (LdCategory *category);
G_END_DECLS
#endif /* ! __LD_CATEGORY_TREE_VIEW_H__ */

View File

@ -1,98 +0,0 @@
/*
* ld-category-view.c
*
* This file is a part of logdiag.
* Copyright 2012 Přemysl Eric Janouch
*
* See the file LICENSE for licensing information.
*
*/
#include "liblogdiag.h"
#include "config.h"
/**
* SECTION:ld-category-view
* @short_description: Interface for objects displaying categories
* @see_also: #LdCategory
*
* #LdCategoryView defines objects displaying contents of #LdCategory
* hierarchies.
*/
G_DEFINE_INTERFACE (LdCategoryView, ld_category_view, 0)
static void
ld_category_view_default_init (LdCategoryViewInterface *iface)
{
GParamSpec *pspec;
/**
* LdCategoryView::symbol-selected:
* @self: an #LdCategoryView object.
* @symbol: the selected #LdSymbol object.
* @path: location of the symbol within the library.
*
* A symbol has been selected.
*/
iface->symbol_selected_signal = g_signal_new
("symbol-selected", G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
ld_marshal_VOID__OBJECT_STRING,
G_TYPE_NONE, 2, LD_TYPE_SYMBOL,
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
* LdCategoryView::symbol-deselected:
* @self: an #LdCategoryView object.
* @symbol: the deselected #LdSymbol object.
* @path: location of the symbol within the library.
*
* A symbol has been deselected.
*/
iface->symbol_deselected_signal = g_signal_new
("symbol-deselected", G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
ld_marshal_VOID__OBJECT_STRING,
G_TYPE_NONE, 2, LD_TYPE_SYMBOL,
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
* LdCategoryView:category:
*
* The #LdCategory this object retrieves content from.
*/
pspec = g_param_spec_object ("category", "Category",
"The symbol category that is shown by this object.",
LD_TYPE_CATEGORY, G_PARAM_READWRITE);
g_object_interface_install_property (iface, pspec);
}
/**
* ld_category_view_set_category:
* @self: an #LdCategoryView object.
* @category: the #LdCategory to be assigned to the view.
*
* Assign an #LdCategory object to the view.
*/
void
ld_category_view_set_category (LdCategoryView *self, LdCategory *category)
{
g_return_if_fail (LD_IS_CATEGORY_VIEW (self));
LD_CATEGORY_VIEW_GET_INTERFACE (self)->set_category (self, category);
}
/**
* ld_category_view_get_category:
* @self: an #LdCategoryView object.
*
* Get the #LdCategory object assigned to this view.
* The reference count on the category is not incremented.
*/
LdCategory *
ld_category_view_get_category (LdCategoryView *self)
{
g_return_val_if_fail (LD_IS_CATEGORY_VIEW (self), NULL);
return LD_CATEGORY_VIEW_GET_INTERFACE (self)->get_category (self);
}

View File

@ -1,59 +0,0 @@
/*
* ld-category-view.h
*
* This file is a part of logdiag.
* Copyright 2012 Přemysl Eric Janouch
*
* See the file LICENSE for licensing information.
*
*/
#ifndef __LD_CATEGORY_VIEW_H__
#define __LD_CATEGORY_VIEW_H__
G_BEGIN_DECLS
#define LD_TYPE_CATEGORY_VIEW (ld_category_view_get_type ())
#define LD_CATEGORY_VIEW(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_CATEGORY_VIEW, LdCategoryView))
#define LD_IS_CATEGORY_VIEW(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_CATEGORY_VIEW))
#define LD_CATEGORY_VIEW_GET_INTERFACE(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), \
LD_TYPE_CATEGORY_VIEW, \
LdCategoryViewInterface))
typedef struct _LdCategoryView LdCategoryView;
typedef struct _LdCategoryViewInterface LdCategoryViewInterface;
/**
* LdCategoryView:
*/
struct _LdCategoryView
{
/* Just to remind gtk-doc that this really exists. */
};
struct _LdCategoryViewInterface
{
/*< private >*/
GTypeInterface parent;
guint symbol_selected_signal;
guint symbol_deselected_signal;
void (*set_category) (LdCategoryView *self, LdCategory *category);
LdCategory *(*get_category) (LdCategoryView *self);
};
GType ld_category_view_get_type (void) G_GNUC_CONST;
void ld_category_view_set_category (LdCategoryView *self, LdCategory *category);
LdCategory *ld_category_view_get_category (LdCategoryView *self);
G_END_DECLS
#endif /* ! __LD_CATEGORY_VIEW_H__ */

View File

@ -1,563 +0,0 @@
/*
* ld-category.c
*
* This file is a part of logdiag.
* Copyright 2010, 2011, 2012 Přemysl Eric Janouch
*
* See the file LICENSE for licensing information.
*
*/
#include "liblogdiag.h"
#include "config.h"
/**
* SECTION:ld-category
* @short_description: A category of symbols
* @see_also: #LdSymbol, #LdLibrary
*
* #LdCategory represents a category of #LdSymbol objects.
*/
/*
* LdCategoryPrivate:
* @parent: the parent of this category.
* @name: the name of this category.
* @human_name: the localized human-readable name of this category.
* @symbols: (element-type LdSymbol *): symbols in this category.
* @subcategories: (element-type LdCategory *) children of this category.
*/
struct _LdCategoryPrivate
{
LdCategory *parent;
gchar *name;
gchar *human_name;
GSList *symbols;
GSList *subcategories;
};
enum
{
PROP_0,
PROP_PARENT,
PROP_NAME,
PROP_HUMAN_NAME
};
static void ld_category_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec);
static void ld_category_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec);
static void ld_category_finalize (GObject *gobject);
static void on_category_notify_name (LdCategory *category,
GParamSpec *pspec, gpointer user_data);
G_DEFINE_TYPE (LdCategory, ld_category, G_TYPE_OBJECT)
static void
ld_category_class_init (LdCategoryClass *klass)
{
GObjectClass *object_class;
GParamSpec *pspec;
object_class = G_OBJECT_CLASS (klass);
object_class->get_property = ld_category_get_property;
object_class->set_property = ld_category_set_property;
object_class->finalize = ld_category_finalize;
/**
* LdCategory:parent:
*
* The parent of this symbol category.
*/
pspec = g_param_spec_string ("parent", "Parent",
"The parent of this symbol category.",
"", G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_PARENT, pspec);
/**
* LdCategory:name:
*
* The name of this symbol category.
*/
pspec = g_param_spec_string ("name", "Name",
"The name of this symbol category.",
"", G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_NAME, pspec);
/**
* LdCategory:human-name:
*
* The localized human name of this symbol category.
*/
pspec = g_param_spec_string ("human-name", "Human name",
"The localized human name of this symbol category.",
"", G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_HUMAN_NAME, pspec);
/**
* LdCategory::symbols-changed:
*
* The list of symbols has changed.
*/
klass->symbols_changed_signal = g_signal_new
("symbols-changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
/**
* LdCategory::children-changed:
*
* The list of subcategory children has changed.
*/
klass->children_changed_signal = g_signal_new
("children-changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
g_type_class_add_private (klass, sizeof (LdCategoryPrivate));
}
static void
ld_category_init (LdCategory *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE
(self, LD_TYPE_CATEGORY, LdCategoryPrivate);
}
static void
ld_category_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec)
{
LdCategory *self;
self = LD_CATEGORY (object);
switch (property_id)
{
case PROP_NAME:
g_value_set_string (value, ld_category_get_name (self));
break;
case PROP_HUMAN_NAME:
g_value_set_string (value, ld_category_get_human_name (self));
break;
case PROP_PARENT:
g_value_set_object (value, ld_category_get_parent (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
ld_category_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec)
{
LdCategory *self;
self = LD_CATEGORY (object);
switch (property_id)
{
case PROP_NAME:
ld_category_set_name (self, g_value_get_string (value));
break;
case PROP_HUMAN_NAME:
ld_category_set_human_name (self, g_value_get_string (value));
break;
case PROP_PARENT:
ld_category_set_parent (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
uninstall_category_cb (LdCategory *category, LdCategory *self)
{
g_signal_handlers_disconnect_by_func (category,
on_category_notify_name, self);
if (ld_category_get_parent (category) == self)
ld_category_set_parent (category, NULL);
g_object_unref (category);
}
static void
parent_weak_notify (gpointer data, GObject *object)
{
LdCategory *self;
/* In practice this should never happen, for it would mean that
* we have a parent that have us as its child.
*/
self = (LdCategory *) data;
if (self->priv->parent)
{
self->priv->parent = NULL;
g_object_notify (G_OBJECT (self), "parent");
}
}
static void
ld_category_finalize (GObject *gobject)
{
LdCategory *self;
self = LD_CATEGORY (gobject);
if (self->priv->parent)
g_object_weak_unref
(G_OBJECT (self->priv->parent), parent_weak_notify, self);
if (self->priv->name)
g_free (self->priv->name);
if (self->priv->human_name)
g_free (self->priv->human_name);
g_slist_foreach (self->priv->symbols, (GFunc) g_object_unref, NULL);
g_slist_free (self->priv->symbols);
g_slist_foreach (self->priv->subcategories,
(GFunc) uninstall_category_cb, self);
g_slist_free (self->priv->subcategories);
/* Chain up to the parent class. */
G_OBJECT_CLASS (ld_category_parent_class)->finalize (gobject);
}
/**
* ld_category_new:
* @name: the name of the new category.
* @human_name: the localized human name of the new category.
*
* Create an instance.
*/
LdCategory *
ld_category_new (const gchar *name, const gchar *human_name)
{
LdCategory *cat;
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (human_name != NULL, NULL);
cat = g_object_new (LD_TYPE_CATEGORY, NULL);
cat->priv->name = g_strdup (name);
cat->priv->human_name = g_strdup (human_name);
return cat;
}
/**
* ld_category_set_name:
* @self: an #LdCategory object.
* @name: the new name for this category.
*/
void
ld_category_set_name (LdCategory *self, const gchar *name)
{
g_return_if_fail (LD_IS_CATEGORY (self));
g_return_if_fail (name != NULL);
if (self->priv->name)
g_free (self->priv->name);
self->priv->name = g_strdup (name);
g_object_notify (G_OBJECT (self), "name");
}
/**
* ld_category_get_name:
* @self: an #LdCategory object.
*
* Return the name of this category.
*/
const gchar *
ld_category_get_name (LdCategory *self)
{
g_return_val_if_fail (LD_IS_CATEGORY (self), NULL);
return self->priv->name;
}
/**
* ld_category_set_human_name:
* @self: an #LdCategory object.
* @human_name: the new localized human name for this category.
*/
void
ld_category_set_human_name (LdCategory *self, const gchar *human_name)
{
g_return_if_fail (LD_IS_CATEGORY (self));
g_return_if_fail (human_name != NULL);
if (self->priv->human_name)
g_free (self->priv->human_name);
self->priv->human_name = g_strdup (human_name);
g_object_notify (G_OBJECT (self), "human-name");
}
/**
* ld_category_get_human_name:
* @self: an #LdCategory object.
*
* Return the localized human name of this category.
*/
const gchar *
ld_category_get_human_name (LdCategory *self)
{
g_return_val_if_fail (LD_IS_CATEGORY (self), NULL);
return self->priv->human_name;
}
/**
* ld_category_insert_symbol:
* @self: an #LdCategory object.
* @symbol: the symbol to be inserted.
* @pos: the position at which the symbol will be inserted.
* Negative values will append to the end of list.
*
* Insert a symbol into the category.
*
* Return value: %TRUE if successful (no name collisions).
*/
gboolean
ld_category_insert_symbol (LdCategory *self, LdSymbol *symbol, gint pos)
{
const gchar *name;
const GSList *iter;
g_return_val_if_fail (LD_IS_CATEGORY (self), FALSE);
g_return_val_if_fail (LD_IS_SYMBOL (symbol), FALSE);
/* Check for name collisions. */
name = ld_symbol_get_name (symbol);
for (iter = self->priv->symbols; iter; iter = iter->next)
{
if (!strcmp (name, ld_symbol_get_name (iter->data)))
{
g_warning ("attempted to insert multiple `%s' symbols into"
" category `%s'", name, ld_category_get_name (self));
return FALSE;
}
}
self->priv->symbols = g_slist_insert (self->priv->symbols, symbol, pos);
g_object_ref (symbol);
g_signal_emit (self,
LD_CATEGORY_GET_CLASS (self)->symbols_changed_signal, 0);
return TRUE;
}
/**
* ld_category_remove_symbol:
* @self: an #LdCategory object.
* @symbol: the symbol to be removed.
*
* Removes a symbol from the category.
*/
void
ld_category_remove_symbol (LdCategory *self, LdSymbol *symbol)
{
GSList *link;
g_return_if_fail (LD_IS_CATEGORY (self));
g_return_if_fail (LD_IS_SYMBOL (symbol));
if ((link = g_slist_find (self->priv->symbols, symbol)))
{
self->priv->symbols = g_slist_delete_link (self->priv->symbols, link);
g_object_unref (symbol);
g_signal_emit (self,
LD_CATEGORY_GET_CLASS (self)->symbols_changed_signal, 0);
}
}
/**
* ld_category_get_symbols:
* @self: an #LdCategory object.
*
* Return value: (element-type LdSymbol *): a list of symbols. Do not modify.
*/
const GSList *
ld_category_get_symbols (LdCategory *self)
{
g_return_val_if_fail (LD_IS_CATEGORY (self), NULL);
return self->priv->symbols;
}
/**
* ld_category_set_parent:
* @self: an #LdCategory object.
* @parent: the new parent category.
*
* Set the parent of this category.
*/
void
ld_category_set_parent (LdCategory *self, LdCategory *parent)
{
g_return_if_fail (LD_IS_CATEGORY (self));
g_return_if_fail (parent == NULL || LD_IS_CATEGORY (parent));
if (self->priv->parent)
g_object_weak_unref
(G_OBJECT (self->priv->parent), parent_weak_notify, self);
self->priv->parent = parent;
if (parent)
g_object_weak_ref (G_OBJECT (parent), parent_weak_notify, self);
g_object_notify (G_OBJECT (self), "parent");
}
/**
* ld_category_get_parent:
* @self: an #LdCategory object.
*
* Return value: the parent of this category.
*/
LdCategory *
ld_category_get_parent (LdCategory *self)
{
g_return_val_if_fail (LD_IS_CATEGORY (self), NULL);
return self->priv->parent;
}
/**
* ld_category_get_path:
* @self: an #LdCategory object.
*
* Return value: the path to this category within the library.
*/
gchar *
ld_category_get_path (LdCategory *self)
{
LdCategory *iter;
gchar *path = NULL, *new_path;
g_return_val_if_fail (LD_IS_CATEGORY (self), NULL);
for (iter = self; iter; iter = ld_category_get_parent (iter))
{
const gchar *name;
/* Stop at the root category. */
name = ld_category_get_name (iter);
if (!strcmp (name, LD_LIBRARY_IDENTIFIER_SEPARATOR))
break;
new_path = g_build_path
(LD_LIBRARY_IDENTIFIER_SEPARATOR, name, path, NULL);
g_free (path);
path = new_path;
}
return path;
}
static void
on_category_notify_name (LdCategory *category,
GParamSpec *pspec, gpointer user_data)
{
LdCategory *self;
self = (LdCategory *) user_data;
g_warning ("name of a library subcategory has changed");
/* The easy way of handling it. */
g_object_ref (category);
ld_category_remove_child (self, category);
ld_category_add_child (self, category);
g_object_unref (category);
}
/**
* ld_category_add_child:
* @self: an #LdCategory object.
* @category: the category to be inserted.
*
* Insert a subcategory into the category.
*
* Return value: %TRUE if successful (no name collisions).
*/
gboolean
ld_category_add_child (LdCategory *self, LdCategory *category)
{
const gchar *name;
GSList *iter;
g_return_val_if_fail (LD_IS_CATEGORY (self), FALSE);
g_return_val_if_fail (LD_IS_CATEGORY (category), FALSE);
name = ld_category_get_name (category);
for (iter = self->priv->subcategories; iter; iter = iter->next)
{
gint comp;
comp = g_utf8_collate (name, ld_category_get_name (iter->data));
if (!comp)
{
g_warning ("attempted to insert multiple `%s' subcategories into"
" category `%s'", name, ld_category_get_name (self));
return FALSE;
}
if (comp < 0)
break;
}
g_signal_connect (category, "notify::name",
G_CALLBACK (on_category_notify_name), self);
self->priv->subcategories = g_slist_insert_before
(self->priv->subcategories, iter, category);
ld_category_set_parent (category, self);
g_object_ref (category);
g_signal_emit (self,
LD_CATEGORY_GET_CLASS (self)->children_changed_signal, 0);
return TRUE;
}
/**
* ld_category_remove_child:
* @self: an #LdCategory object.
* @category: the category to be removed.
*
* Removes a subcategory from the category.
*/
void
ld_category_remove_child (LdCategory *self, LdCategory *category)
{
GSList *link;
g_return_if_fail (LD_IS_CATEGORY (self));
g_return_if_fail (LD_IS_CATEGORY (category));
if ((link = g_slist_find (self->priv->subcategories, category)))
{
self->priv->subcategories
= g_slist_delete_link (self->priv->subcategories, link);
uninstall_category_cb (category, self);
g_signal_emit (self,
LD_CATEGORY_GET_CLASS (self)->children_changed_signal, 0);
}
}
/**
* ld_category_get_children:
* @self: an #LdCategory object.
*
* Return value: (element-type LdCategory *):
* a list of subcategories. Do not modify.
*/
const GSList *
ld_category_get_children (LdCategory *self)
{
g_return_val_if_fail (LD_IS_CATEGORY (self), NULL);
return self->priv->subcategories;
}

View File

@ -1,79 +0,0 @@
/*
* ld-category.h
*
* This file is a part of logdiag.
* Copyright 2010, 2012 Přemysl Eric Janouch
*
* See the file LICENSE for licensing information.
*
*/
#ifndef __LD_CATEGORY_H__
#define __LD_CATEGORY_H__
G_BEGIN_DECLS
#define LD_TYPE_CATEGORY (ld_category_get_type ())
#define LD_CATEGORY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_CATEGORY, LdCategory))
#define LD_CATEGORY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_CATEGORY, LdCategoryClass))
#define LD_IS_CATEGORY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_CATEGORY))
#define LD_IS_CATEGORY_CLASS(klass) \
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_CATEGORY))
#define LD_CATEGORY_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_CATEGORY, LdCategoryClass))
typedef struct _LdCategory LdCategory;
typedef struct _LdCategoryPrivate LdCategoryPrivate;
typedef struct _LdCategoryClass LdCategoryClass;
/**
* LdCategory:
*/
struct _LdCategory
{
/*< private >*/
GObject parent_instance;
LdCategoryPrivate *priv;
};
struct _LdCategoryClass
{
/*< private >*/
GObjectClass parent_class;
guint symbols_changed_signal;
guint children_changed_signal;
};
GType ld_category_get_type (void) G_GNUC_CONST;
LdCategory *ld_category_new (const gchar *name, const gchar *human_name);
void ld_category_set_name (LdCategory *self, const gchar *name);
const gchar *ld_category_get_name (LdCategory *self);
void ld_category_set_human_name (LdCategory *self, const gchar *human_name);
const gchar *ld_category_get_human_name (LdCategory *self);
gboolean ld_category_insert_symbol (LdCategory *self,
LdSymbol *symbol, gint pos);
void ld_category_remove_symbol (LdCategory *self, LdSymbol *symbol);
const GSList *ld_category_get_symbols (LdCategory *self);
void ld_category_set_parent (LdCategory *self, LdCategory *parent);
LdCategory *ld_category_get_parent (LdCategory *self);
gchar *ld_category_get_path (LdCategory *self);
gboolean ld_category_add_child (LdCategory *self, LdCategory *category);
void ld_category_remove_child (LdCategory *self, LdCategory *category);
const GSList *ld_category_get_children (LdCategory *self);
G_END_DECLS
#endif /* ! __LD_CATEGORY_H__ */

View File

@ -2,7 +2,7 @@
* ld-diagram-connection.c * ld-diagram-connection.c
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -57,7 +57,7 @@ static void on_set_points_destroy (gpointer user_data);
G_DEFINE_TYPE (LdDiagramConnection, ld_diagram_connection, G_DEFINE_TYPE (LdDiagramConnection, ld_diagram_connection,
LD_TYPE_DIAGRAM_OBJECT) LD_TYPE_DIAGRAM_OBJECT);
static void static void
ld_diagram_connection_class_init (LdDiagramConnectionClass *klass) ld_diagram_connection_class_init (LdDiagramConnectionClass *klass)
@ -98,7 +98,7 @@ ld_diagram_connection_get_property (GObject *object, guint property_id,
case PROP_POINTS: case PROP_POINTS:
points = ld_diagram_connection_get_points (self); points = ld_diagram_connection_get_points (self);
g_value_take_boxed (value, points); g_value_set_boxed_take_ownership (value, points);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -332,3 +332,4 @@ on_set_points_destroy (gpointer user_data)
json_node_free (data->new_node); json_node_free (data->new_node);
g_slice_free (SetPointsActionData, data); g_slice_free (SetPointsActionData, data);
} }

View File

@ -2,7 +2,7 @@
* ld-diagram-connection.h * ld-diagram-connection.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -15,22 +15,16 @@ G_BEGIN_DECLS
#define LD_TYPE_DIAGRAM_CONNECTION (ld_diagram_connection_get_type ()) #define LD_TYPE_DIAGRAM_CONNECTION (ld_diagram_connection_get_type ())
#define LD_DIAGRAM_CONNECTION(obj) \ #define LD_DIAGRAM_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \ ((obj), LD_TYPE_DIAGRAM_CONNECTION, LdDiagramConnection))
LD_TYPE_DIAGRAM_CONNECTION, \ #define LD_DIAGRAM_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
LdDiagramConnection)) ((klass), LD_TYPE_DIAGRAM_CONNECTION, LdDiagramConnectionClass))
#define LD_DIAGRAM_CONNECTION_CLASS(klass) \ #define LD_IS_DIAGRAM_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
(G_TYPE_CHECK_CLASS_CAST ((klass), \ ((obj), LD_TYPE_DIAGRAM_CONNECTION))
LD_TYPE_DIAGRAM_CONNECTION, \ #define LD_IS_DIAGRAM_CONNECTION_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
LdDiagramConnectionClass)) ((klass), LD_TYPE_DIAGRAM_CONNECTION))
#define LD_IS_DIAGRAM_CONNECTION(obj) \ #define LD_DIAGRAM_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_DIAGRAM_CONNECTION)) ((obj), LD_DIAGRAM_CONNECTION, LdDiagramConnectionClass))
#define LD_IS_DIAGRAM_CONNECTION_CLASS(klass) \
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_DIAGRAM_CONNECTION))
#define LD_DIAGRAM_CONNECTION_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
LD_DIAGRAM_CONNECTION, \
LdDiagramConnectionClass))
typedef struct _LdDiagramConnection LdDiagramConnection; typedef struct _LdDiagramConnection LdDiagramConnection;
typedef struct _LdDiagramConnectionPrivate LdDiagramConnectionPrivate; typedef struct _LdDiagramConnectionPrivate LdDiagramConnectionPrivate;
@ -67,3 +61,4 @@ void ld_diagram_connection_set_points (LdDiagramConnection *self,
G_END_DECLS G_END_DECLS
#endif /* ! __LD_DIAGRAM_CONNECTION_H__ */ #endif /* ! __LD_DIAGRAM_CONNECTION_H__ */

View File

@ -2,7 +2,7 @@
* ld-diagram-object.c * ld-diagram-object.c
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -69,7 +69,7 @@ static void on_set_param_redo (gpointer user_data);
static void on_set_param_destroy (gpointer user_data); static void on_set_param_destroy (gpointer user_data);
G_DEFINE_TYPE (LdDiagramObject, ld_diagram_object, G_TYPE_OBJECT) G_DEFINE_TYPE (LdDiagramObject, ld_diagram_object, G_TYPE_OBJECT);
static void static void
ld_diagram_object_class_init (LdDiagramObjectClass *klass) ld_diagram_object_class_init (LdDiagramObjectClass *klass)
@ -221,12 +221,8 @@ JsonObject *
ld_diagram_object_get_storage (LdDiagramObject *self) ld_diagram_object_get_storage (LdDiagramObject *self)
{ {
g_return_val_if_fail (LD_IS_DIAGRAM_OBJECT (self), NULL); g_return_val_if_fail (LD_IS_DIAGRAM_OBJECT (self), NULL);
if (!self->priv->storage) if (!self->priv->storage)
{
self->priv->storage = json_object_new (); self->priv->storage = json_object_new ();
g_object_notify (G_OBJECT (self), "storage");
}
return self->priv->storage; return self->priv->storage;
} }
@ -249,8 +245,6 @@ ld_diagram_object_set_storage (LdDiagramObject *self, JsonObject *storage)
self->priv->storage = json_object_ref (storage); self->priv->storage = json_object_ref (storage);
else else
self->priv->storage = NULL; self->priv->storage = NULL;
g_object_notify (G_OBJECT (self), "storage");
} }
/** /**

View File

@ -2,7 +2,7 @@
* ld-diagram-object.h * ld-diagram-object.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -15,20 +15,16 @@ G_BEGIN_DECLS
#define LD_TYPE_DIAGRAM_OBJECT (ld_diagram_object_get_type ()) #define LD_TYPE_DIAGRAM_OBJECT (ld_diagram_object_get_type ())
#define LD_DIAGRAM_OBJECT(obj) \ #define LD_DIAGRAM_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \ ((obj), LD_TYPE_DIAGRAM_OBJECT, LdDiagramObject))
LD_TYPE_DIAGRAM_OBJECT, \ #define LD_DIAGRAM_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
LdDiagramObject)) ((klass), LD_TYPE_DIAGRAM_OBJECT, LdDiagramObjectClass))
#define LD_DIAGRAM_OBJECT_CLASS(klass) \ #define LD_IS_DIAGRAM_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
(G_TYPE_CHECK_CLASS_CAST ((klass), \ ((obj), LD_TYPE_DIAGRAM_OBJECT))
LD_TYPE_DIAGRAM_OBJECT, \ #define LD_IS_DIAGRAM_OBJECT_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
LdDiagramObjectClass)) ((klass), LD_TYPE_DIAGRAM_OBJECT))
#define LD_IS_DIAGRAM_OBJECT(obj) \ #define LD_DIAGRAM_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_DIAGRAM_OBJECT)) ((obj), LD_DIAGRAM_OBJECT, LdDiagramObjectClass))
#define LD_IS_DIAGRAM_OBJECT_CLASS(klass) \
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_DIAGRAM_OBJECT))
#define LD_DIAGRAM_OBJECT_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_DIAGRAM_OBJECT, LdDiagramObjectClass))
typedef struct _LdDiagramObject LdDiagramObject; typedef struct _LdDiagramObject LdDiagramObject;
typedef struct _LdDiagramObjectPrivate LdDiagramObjectPrivate; typedef struct _LdDiagramObjectPrivate LdDiagramObjectPrivate;
@ -78,3 +74,4 @@ void ld_diagram_object_set_y (LdDiagramObject *self, gdouble y);
G_END_DECLS G_END_DECLS
#endif /* ! __LD_DIAGRAM_OBJECT_H__ */ #endif /* ! __LD_DIAGRAM_OBJECT_H__ */

View File

@ -2,7 +2,7 @@
* ld-diagram-symbol.c * ld-diagram-symbol.c
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -33,7 +33,7 @@ static void ld_diagram_symbol_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec); const GValue *value, GParamSpec *pspec);
G_DEFINE_TYPE (LdDiagramSymbol, ld_diagram_symbol, LD_TYPE_DIAGRAM_OBJECT) G_DEFINE_TYPE (LdDiagramSymbol, ld_diagram_symbol, LD_TYPE_DIAGRAM_OBJECT);
static void static void
ld_diagram_symbol_class_init (LdDiagramSymbolClass *klass) ld_diagram_symbol_class_init (LdDiagramSymbolClass *klass)

View File

@ -2,7 +2,7 @@
* ld-diagram-symbol.h * ld-diagram-symbol.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -15,20 +15,16 @@ G_BEGIN_DECLS
#define LD_TYPE_DIAGRAM_SYMBOL (ld_diagram_symbol_get_type ()) #define LD_TYPE_DIAGRAM_SYMBOL (ld_diagram_symbol_get_type ())
#define LD_DIAGRAM_SYMBOL(obj) \ #define LD_DIAGRAM_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \ ((obj), LD_TYPE_DIAGRAM_SYMBOL, LdDiagramSymbol))
LD_TYPE_DIAGRAM_SYMBOL, \ #define LD_DIAGRAM_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
LdDiagramSymbol)) ((klass), LD_TYPE_DIAGRAM_SYMBOL, LdDiagramSymbolClass))
#define LD_DIAGRAM_SYMBOL_CLASS(klass) \ #define LD_IS_DIAGRAM_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
(G_TYPE_CHECK_CLASS_CAST ((klass), \ ((obj), LD_TYPE_DIAGRAM_SYMBOL))
LD_TYPE_DIAGRAM_SYMBOL, \ #define LD_IS_DIAGRAM_SYMBOL_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
LdDiagramSymbolClass)) ((klass), LD_TYPE_DIAGRAM_SYMBOL))
#define LD_IS_DIAGRAM_SYMBOL(obj) \ #define LD_DIAGRAM_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_DIAGRAM_SYMBOL)) ((obj), LD_DIAGRAM_SYMBOL, LdDiagramSymbolClass))
#define LD_IS_DIAGRAM_SYMBOL_CLASS(klass) \
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_DIAGRAM_SYMBOL))
#define LD_DIAGRAM_SYMBOL_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_DIAGRAM_SYMBOL, LdDiagramSymbolClass))
typedef struct _LdDiagramSymbol LdDiagramSymbol; typedef struct _LdDiagramSymbol LdDiagramSymbol;
typedef struct _LdDiagramSymbolPrivate LdDiagramSymbolPrivate; typedef struct _LdDiagramSymbolPrivate LdDiagramSymbolPrivate;
@ -74,3 +70,4 @@ void ld_diagram_symbol_set_rotation (LdDiagramSymbol *self, gint rotation);
G_END_DECLS G_END_DECLS
#endif /* ! __LD_DIAGRAM_SYMBOL_H__ */ #endif /* ! __LD_DIAGRAM_SYMBOL_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
* ld-diagram-view.h * ld-diagram-view.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010 - 2021 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -15,18 +15,16 @@ G_BEGIN_DECLS
#define LD_TYPE_DIAGRAM_VIEW (ld_diagram_view_get_type ()) #define LD_TYPE_DIAGRAM_VIEW (ld_diagram_view_get_type ())
#define LD_DIAGRAM_VIEW(obj) \ #define LD_DIAGRAM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_DIAGRAM_VIEW, LdDiagramView)) ((obj), LD_TYPE_DIAGRAM_VIEW, LdDiagramView))
#define LD_DIAGRAM_VIEW_CLASS(klass) \ #define LD_DIAGRAM_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
(G_TYPE_CHECK_CLASS_CAST ((klass), \ ((klass), LD_TYPE_DIAGRAM_VIEW, LdDiagramViewClass))
LD_TYPE_DIAGRAM_VIEW, \ #define LD_IS_DIAGRAM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
LdDiagramViewClass)) ((obj), LD_TYPE_DIAGRAM_VIEW))
#define LD_IS_DIAGRAM_VIEW(obj) \ #define LD_IS_DIAGRAM_VIEW_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_DIAGRAM_VIEW)) ((klass), LD_TYPE_DIAGRAM_VIEW))
#define LD_IS_DIAGRAM_VIEW_CLASS(klass) \ #define LD_DIAGRAM_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_DIAGRAM_VIEW)) ((obj), LD_DIAGRAM_VIEW, LdDiagramViewClass))
#define LD_DIAGRAM_VIEW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_DIAGRAM_VIEW, LdDiagramViewClass))
typedef struct _LdDiagramView LdDiagramView; typedef struct _LdDiagramView LdDiagramView;
typedef struct _LdDiagramViewPrivate LdDiagramViewPrivate; typedef struct _LdDiagramViewPrivate LdDiagramViewPrivate;
@ -51,6 +49,8 @@ struct _LdDiagramViewClass
guint cancel_operation_signal; guint cancel_operation_signal;
guint move_signal; guint move_signal;
void (*set_scroll_adjustments) (LdDiagramView *self,
GtkAdjustment *horizontal, GtkAdjustment *vertical);
void (*cancel_operation) (LdDiagramView *self); void (*cancel_operation) (LdDiagramView *self);
void (*move) (LdDiagramView *self, gdouble dx, gdouble dy); void (*move) (LdDiagramView *self, gdouble dx, gdouble dy);
}; };
@ -90,17 +90,9 @@ void ld_diagram_view_zoom_in (LdDiagramView *self);
gboolean ld_diagram_view_can_zoom_out (LdDiagramView *self); gboolean ld_diagram_view_can_zoom_out (LdDiagramView *self);
void ld_diagram_view_zoom_out (LdDiagramView *self); void ld_diagram_view_zoom_out (LdDiagramView *self);
gboolean ld_diagram_view_get_show_grid (LdDiagramView *self);
void ld_diagram_view_set_show_grid (LdDiagramView *self, gboolean show_grid);
void ld_diagram_view_add_object_begin (LdDiagramView *self, void ld_diagram_view_add_object_begin (LdDiagramView *self,
LdDiagramObject *object); LdDiagramObject *object);
gdouble ld_diagram_view_get_export_bounds (LdDiagramView *self,
LdRectangle *rect);
void ld_diagram_view_export (LdDiagramView *self,
cairo_t *cr, const LdRectangle *clip);
G_END_DECLS G_END_DECLS

View File

@ -2,7 +2,7 @@
* ld-diagram.c * ld-diagram.c
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011, 2012 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -31,6 +31,7 @@
* each containing a #GList of #LdUndoAction subactions. * each containing a #GList of #LdUndoAction subactions.
* @objects: all objects in the diagram. * @objects: all objects in the diagram.
* @selection: all currently selected objects. * @selection: all currently selected objects.
* @connections: connections between objects.
*/ */
struct _LdDiagramPrivate struct _LdDiagramPrivate
{ {
@ -42,6 +43,7 @@ struct _LdDiagramPrivate
GList *objects; GList *objects;
GList *selection; GList *selection;
GList *connections;
}; };
typedef struct _ObjectActionData ObjectActionData; typedef struct _ObjectActionData ObjectActionData;
@ -54,7 +56,7 @@ typedef struct _ObjectActionData ObjectActionData;
*/ */
struct _ObjectActionData struct _ObjectActionData
{ {
gpointer self; LdDiagram *self;
LdDiagramObject *object; LdDiagramObject *object;
gint pos; gint pos;
}; };
@ -74,7 +76,6 @@ static void ld_diagram_set_property (GObject *object, guint property_id,
static void ld_diagram_dispose (GObject *gobject); static void ld_diagram_dispose (GObject *gobject);
static void ld_diagram_finalize (GObject *gobject); static void ld_diagram_finalize (GObject *gobject);
static void ld_diagram_real_changed (LdDiagram *self); static void ld_diagram_real_changed (LdDiagram *self);
static void ld_diagram_clear_internal (LdDiagram *self, gboolean emit_signals);
static gboolean write_signature (GOutputStream *stream, GError **error); static gboolean write_signature (GOutputStream *stream, GError **error);
@ -105,7 +106,7 @@ static void uninstall_object (LdDiagramObject *object, LdDiagram *self);
static void ld_diagram_unselect_all_internal (LdDiagram *self); static void ld_diagram_unselect_all_internal (LdDiagram *self);
G_DEFINE_TYPE (LdDiagram, ld_diagram, G_TYPE_OBJECT) G_DEFINE_TYPE (LdDiagram, ld_diagram, G_TYPE_OBJECT);
static void static void
ld_diagram_class_init (LdDiagramClass *klass) ld_diagram_class_init (LdDiagramClass *klass)
@ -231,7 +232,7 @@ ld_diagram_dispose (GObject *gobject)
LdDiagram *self; LdDiagram *self;
self = LD_DIAGRAM (gobject); self = LD_DIAGRAM (gobject);
ld_diagram_clear_internal (self, FALSE); ld_diagram_clear (self);
/* Chain up to the parent class. */ /* Chain up to the parent class. */
G_OBJECT_CLASS (ld_diagram_parent_class)->dispose (gobject); G_OBJECT_CLASS (ld_diagram_parent_class)->dispose (gobject);
@ -285,23 +286,24 @@ ld_diagram_new (void)
*/ */
void void
ld_diagram_clear (LdDiagram *self) ld_diagram_clear (LdDiagram *self)
{
g_return_if_fail (LD_IS_DIAGRAM (self));
ld_diagram_clear_internal (self, TRUE);
}
static void
ld_diagram_clear_internal (LdDiagram *self, gboolean emit_signals)
{ {
gboolean changed = FALSE; gboolean changed = FALSE;
gboolean selection_changed = FALSE; gboolean selection_changed = FALSE;
g_return_if_fail (LD_IS_DIAGRAM (self));
if (self->priv->selection) if (self->priv->selection)
{ {
ld_diagram_unselect_all_internal (self); ld_diagram_unselect_all_internal (self);
selection_changed = TRUE; selection_changed = TRUE;
} }
if (self->priv->connections)
{
g_list_free (self->priv->connections);
self->priv->connections = NULL;
changed = TRUE;
}
if (self->priv->objects) if (self->priv->objects)
{ {
g_list_foreach (self->priv->objects, (GFunc) uninstall_object, self); g_list_foreach (self->priv->objects, (GFunc) uninstall_object, self);
@ -313,8 +315,6 @@ ld_diagram_clear_internal (LdDiagram *self, gboolean emit_signals)
destroy_action_stack (&self->priv->undo_stack); destroy_action_stack (&self->priv->undo_stack);
destroy_action_stack (&self->priv->redo_stack); destroy_action_stack (&self->priv->redo_stack);
if (emit_signals)
{
g_object_notify (G_OBJECT (self), "can-undo"); g_object_notify (G_OBJECT (self), "can-undo");
g_object_notify (G_OBJECT (self), "can-redo"); g_object_notify (G_OBJECT (self), "can-redo");
@ -324,7 +324,6 @@ ld_diagram_clear_internal (LdDiagram *self, gboolean emit_signals)
if (selection_changed) if (selection_changed)
g_signal_emit (self, g_signal_emit (self,
LD_DIAGRAM_GET_CLASS (self)->selection_changed_signal, 0); LD_DIAGRAM_GET_CLASS (self)->selection_changed_signal, 0);
}
} }
/** /**
@ -810,9 +809,7 @@ on_object_action_remove (gpointer user_data)
ObjectActionData *data; ObjectActionData *data;
data = user_data; data = user_data;
g_return_if_fail (data->self != NULL); ld_diagram_remove_object (data->self, data->object);
ld_diagram_remove_object
((LdDiagram *) data->self, data->object);
} }
static void static void
@ -821,9 +818,7 @@ on_object_action_insert (gpointer user_data)
ObjectActionData *data; ObjectActionData *data;
data = user_data; data = user_data;
g_return_if_fail (data->self != NULL); ld_diagram_insert_object (data->self, data->object, data->pos);
ld_diagram_insert_object
((LdDiagram *) data->self, data->object, data->pos);
} }
static void static void
@ -832,8 +827,7 @@ on_object_action_destroy (gpointer user_data)
ObjectActionData *data; ObjectActionData *data;
data = user_data; data = user_data;
if (data->self) g_object_unref (data->self);
g_object_remove_weak_pointer (G_OBJECT (data->self), &data->self);
g_object_unref (data->object); g_object_unref (data->object);
g_slice_free (ObjectActionData, data); g_slice_free (ObjectActionData, data);
} }
@ -897,8 +891,7 @@ ld_diagram_insert_object (LdDiagram *self, LdDiagramObject *object, gint pos)
install_object (object, self); install_object (object, self);
action_data = g_slice_new (ObjectActionData); action_data = g_slice_new (ObjectActionData);
action_data->self = self; action_data->self = g_object_ref (self);
g_object_add_weak_pointer (G_OBJECT (self), &action_data->self);
action_data->object = g_object_ref (object); action_data->object = g_object_ref (object);
action_data->pos = pos; action_data->pos = pos;
@ -945,8 +938,7 @@ ld_diagram_remove_object (LdDiagram *self, LdDiagramObject *object)
uninstall_object (object, self); uninstall_object (object, self);
action_data = g_slice_new (ObjectActionData); action_data = g_slice_new (ObjectActionData);
action_data->self = self; action_data->self = g_object_ref (self);
g_object_add_weak_pointer (G_OBJECT (self), &action_data->self);
action_data->object = g_object_ref (object); action_data->object = g_object_ref (object);
action_data->pos = pos; action_data->pos = pos;
@ -1032,15 +1024,13 @@ ld_diagram_select (LdDiagram *self, LdDiagramObject *object)
void void
ld_diagram_unselect (LdDiagram *self, LdDiagramObject *object) ld_diagram_unselect (LdDiagram *self, LdDiagramObject *object)
{ {
GList *link;
g_return_if_fail (LD_IS_DIAGRAM (self)); g_return_if_fail (LD_IS_DIAGRAM (self));
g_return_if_fail (LD_IS_DIAGRAM_OBJECT (object)); g_return_if_fail (LD_IS_DIAGRAM_OBJECT (object));
if (!(link = g_list_find (self->priv->selection, object))) if (!g_list_find (self->priv->selection, object))
return; return;
self->priv->selection = g_list_delete_link (self->priv->selection, link); self->priv->selection = g_list_remove (self->priv->selection, object);
g_object_unref (object); g_object_unref (object);
g_signal_emit (self, g_signal_emit (self,

View File

@ -2,7 +2,7 @@
* ld-diagram.h * ld-diagram.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -15,15 +15,16 @@ G_BEGIN_DECLS
#define LD_TYPE_DIAGRAM (ld_diagram_get_type ()) #define LD_TYPE_DIAGRAM (ld_diagram_get_type ())
#define LD_DIAGRAM(obj) \ #define LD_DIAGRAM(obj) (G_TYPE_CHECK_INSTANCE_CAST \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_DIAGRAM, LdDiagram)) ((obj), LD_TYPE_DIAGRAM, LdDiagram))
#define LD_DIAGRAM_CLASS(klass) \ #define LD_DIAGRAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_DIAGRAM, LdDiagramClass)) ((klass), LD_TYPE_DIAGRAM, LdDiagramClass))
#define LD_IS_DIAGRAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_DIAGRAM)) #define LD_IS_DIAGRAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
#define LD_IS_DIAGRAM_CLASS(klass) \ ((obj), LD_TYPE_DIAGRAM))
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_DIAGRAM)) #define LD_IS_DIAGRAM_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
#define LD_DIAGRAM_GET_CLASS(obj) \ ((klass), LD_TYPE_DIAGRAM))
(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_DIAGRAM, LdDiagramClass)) #define LD_DIAGRAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
((obj), LD_DIAGRAM, LdDiagramClass))
typedef struct _LdDiagram LdDiagram; typedef struct _LdDiagram LdDiagram;
typedef struct _LdDiagramClass LdDiagramClass; typedef struct _LdDiagramClass LdDiagramClass;
@ -113,3 +114,4 @@ void ld_diagram_unselect_all (LdDiagram *self);
G_END_DECLS G_END_DECLS
#endif /* ! __LD_DIAGRAM_H__ */ #endif /* ! __LD_DIAGRAM_H__ */

View File

@ -0,0 +1,787 @@
/*
* ld-library-toolbar.c
*
* This file is a part of logdiag.
* Copyright Přemysl Janouch 2011. All rights reserved.
*
* See the file LICENSE for licensing information.
*
*/
#include "liblogdiag.h"
#include "config.h"
/**
* SECTION:ld-library-toolbar
* @short_description: A library toolbar
* @see_also: #LdLibrary
*
* #LdLibraryToolbar enables the user to choose symbols from an #LdLibrary.
*/
#define LIBRARY_TOOLBAR_ICON_WIDTH 32
/*
* SymbolMenuItem:
*
* Data related to a symbol in an open symbol menu.
*/
typedef struct _SymbolMenuItem SymbolMenuItem;
struct _SymbolMenuItem
{
LdSymbol *symbol;
gchar *klass;
gint width;
gdouble dx;
gdouble scale;
};
/*
* SymbolMenuData:
*
* Data related to the currently opened symbol menu.
*/
typedef struct _SymbolMenuData SymbolMenuData;
struct _SymbolMenuData
{
GtkToggleButton *active_button;
SymbolMenuItem *items;
gint n_items;
gint active_item;
gint menu_width;
gint menu_height;
gint menu_y;
};
enum
{
VIEW_HANDLER_EXPOSE,
VIEW_HANDLER_MOTION_NOTIFY,
VIEW_HANDLER_BUTTON_PRESS,
VIEW_HANDLER_BUTTON_RELEASE,
VIEW_HANDLER_COUNT
};
/*
* LdLibraryToolbarPrivate:
* @library: a library object assigned as a model.
* @view: a view widget for showing symbol menus.
* @view_handlers: signal handlers that hook the view.
* @symbol_menu: data related to menus.
*/
struct _LdLibraryToolbarPrivate
{
LdLibrary *library;
LdDiagramView *view;
gulong view_handlers[VIEW_HANDLER_COUNT];
SymbolMenuData symbol_menu;
};
enum
{
PROP_0,
PROP_LIBRARY,
PROP_VIEW
};
static void ld_library_toolbar_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec);
static void ld_library_toolbar_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec);
static void ld_library_toolbar_dispose (GObject *gobject);
static void reload_library (LdLibraryToolbar *self);
static void load_category_cb (gpointer data, gpointer user_data);
static GdkPixbuf *recolor_pixbuf (GdkPixbuf *pbuf, GdkColor *color);
static void redraw_symbol_menu (LdLibraryToolbar *self);
static void emit_symbol_signal (LdLibraryToolbar *self,
guint signal_id, gint menu_index);
static void on_category_toggle (GtkToggleButton *toggle_button,
gpointer user_data);
static inline void block_view_handlers (LdLibraryToolbar *self);
static inline void unblock_view_handlers (LdLibraryToolbar *self);
static inline void disconnect_view_handlers (LdLibraryToolbar *self);
static gboolean on_view_exposed (GtkWidget *widget,
GdkEventExpose *event, gpointer user_data);
static gboolean on_view_motion_notify (GtkWidget *widget,
GdkEventMotion *event, gpointer user_data);
static gboolean on_view_button_press (GtkWidget *widget,
GdkEventButton *event, gpointer user_data);
static gboolean on_view_button_release (GtkWidget *widget,
GdkEventButton *event, gpointer user_data);
G_DEFINE_TYPE (LdLibraryToolbar, ld_library_toolbar, GTK_TYPE_TOOLBAR);
static void
ld_library_toolbar_class_init (LdLibraryToolbarClass *klass)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
GParamSpec *pspec;
widget_class = GTK_WIDGET_CLASS (klass);
object_class = G_OBJECT_CLASS (klass);
object_class->get_property = ld_library_toolbar_get_property;
object_class->set_property = ld_library_toolbar_set_property;
object_class->dispose = ld_library_toolbar_dispose;
/**
* LdLibraryToolbar:library:
*
* The #LdLibrary that this toolbar retrieves symbols from.
*/
pspec = g_param_spec_object ("library", "Library",
"The library that this toolbar retrieves symbols from.",
LD_TYPE_LIBRARY, G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_LIBRARY, pspec);
/**
* LdLibraryToolbar:view:
*
* The #LdDiagramView widget misused for showing symbol menus.
*/
pspec = g_param_spec_object ("view", "View",
"The view widget misused for showing symbol menus.",
LD_TYPE_DIAGRAM_VIEW, G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_VIEW, pspec);
/**
* LdLibraryToolbar::symbol-chosen:
* @self: an #LdLibraryToolbar object.
* @symbol: the chosen #LdSymbol object.
* @klass: location of the symbol within the library.
*
* A symbol has been chosen.
*/
klass->symbol_chosen_signal = g_signal_new
("symbol-chosen", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
ld_marshal_VOID__OBJECT_STRING,
G_TYPE_NONE, 2, LD_TYPE_SYMBOL,
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
* LdLibraryToolbar::symbol-selected:
* @self: an #LdLibraryToolbar object.
* @symbol: the selected #LdSymbol object.
* @klass: location of the symbol within the library.
*
* A symbol has been selected.
*/
klass->symbol_selected_signal = g_signal_new
("symbol-selected", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
ld_marshal_VOID__OBJECT_STRING,
G_TYPE_NONE, 2, LD_TYPE_SYMBOL,
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
* LdLibraryToolbar::symbol-deselected:
* @self: an #LdLibraryToolbar object.
* @symbol: the deselected #LdSymbol object.
* @klass: location of the symbol within the library.
*
* A symbol has been deselected.
*/
klass->symbol_deselected_signal = g_signal_new
("symbol-deselected", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
ld_marshal_VOID__OBJECT_STRING,
G_TYPE_NONE, 2, LD_TYPE_SYMBOL,
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
g_type_class_add_private (klass, sizeof (LdLibraryToolbarPrivate));
}
static void
ld_library_toolbar_init (LdLibraryToolbar *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE
(self, LD_TYPE_LIBRARY_TOOLBAR, LdLibraryToolbarPrivate);
}
static void
ld_library_toolbar_dispose (GObject *gobject)
{
LdLibraryToolbar *self;
self = LD_LIBRARY_TOOLBAR (gobject);
ld_library_toolbar_set_library (self, NULL);
ld_library_toolbar_set_view (self, NULL);
/* Chain up to the parent class. */
G_OBJECT_CLASS (ld_library_toolbar_parent_class)->dispose (gobject);
}
static void
ld_library_toolbar_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec)
{
LdLibraryToolbar *self;
self = LD_LIBRARY_TOOLBAR (object);
switch (property_id)
{
case PROP_LIBRARY:
g_value_set_object (value, ld_library_toolbar_get_library (self));
break;
case PROP_VIEW:
g_value_set_object (value, ld_library_toolbar_get_view (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
ld_library_toolbar_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec)
{
LdLibraryToolbar *self;
self = LD_LIBRARY_TOOLBAR (object);
switch (property_id)
{
case PROP_LIBRARY:
ld_library_toolbar_set_library (self,
LD_LIBRARY (g_value_get_object (value)));
break;
case PROP_VIEW:
ld_library_toolbar_set_view (self,
LD_DIAGRAM_VIEW (g_value_get_object (value)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
/**
* ld_library_toolbar_new:
*
* Create an instance.
*/
GtkWidget *
ld_library_toolbar_new (void)
{
return g_object_new (LD_TYPE_LIBRARY_TOOLBAR, NULL);
}
/**
* ld_library_toolbar_set_library:
* @self: an #LdLibraryToolbar object.
* @library: (allow-none): the library to be assigned to the toolbar.
*
* Assign an #LdLibrary object to the toolbar.
*/
void
ld_library_toolbar_set_library (LdLibraryToolbar *self, LdLibrary *library)
{
g_return_if_fail (LD_IS_LIBRARY_TOOLBAR (self));
g_return_if_fail (LD_IS_LIBRARY (library) || library == NULL);
if (self->priv->library)
{
g_signal_handlers_disconnect_by_func (self->priv->library,
reload_library, self);
g_object_unref (self->priv->library);
}
self->priv->library = library;
if (library)
{
g_signal_connect_data (library, "changed",
G_CALLBACK (reload_library), self,
NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_object_ref (library);
}
reload_library (self);
g_object_notify (G_OBJECT (self), "library");
}
/**
* ld_library_toolbar_get_library:
* @self: an #LdLibraryToolbar object.
*
* Return value: (transfer none): the #LdLibrary object
* assigned to the toolbar.
*/
LdLibrary *
ld_library_toolbar_get_library (LdLibraryToolbar *self)
{
g_return_val_if_fail (LD_IS_LIBRARY_TOOLBAR (self), NULL);
return self->priv->library;
}
/**
* ld_library_toolbar_set_view:
* @self: an #LdLibraryToolbar object.
* @view: (allow-none): the widget to be assigned to the toolbar.
*
* Assign an #LdDiagramView widget to the toolbar.
*/
void
ld_library_toolbar_set_view (LdLibraryToolbar *self, LdDiagramView *view)
{
g_return_if_fail (LD_IS_LIBRARY_TOOLBAR (self));
g_return_if_fail (LD_IS_DIAGRAM_VIEW (view) || view == NULL);
if (self->priv->view)
{
disconnect_view_handlers (self);
g_object_unref (self->priv->view);
}
self->priv->view = view;
if (view)
{
self->priv->view_handlers[VIEW_HANDLER_EXPOSE]
= g_signal_connect (view, "expose-event",
G_CALLBACK (on_view_exposed), self);
self->priv->view_handlers[VIEW_HANDLER_MOTION_NOTIFY]
= g_signal_connect (view, "motion-notify-event",
G_CALLBACK (on_view_motion_notify), self);
self->priv->view_handlers[VIEW_HANDLER_BUTTON_PRESS]
= g_signal_connect (view, "button-press-event",
G_CALLBACK (on_view_button_press), self);
self->priv->view_handlers[VIEW_HANDLER_BUTTON_RELEASE]
= g_signal_connect (view, "button-release-event",
G_CALLBACK (on_view_button_release), self);
block_view_handlers (self);
g_object_ref (view);
}
g_object_notify (G_OBJECT (self), "view");
}
/**
* ld_library_toolbar_get_view:
* @self: an #LdLibraryToolbar object.
*
* Return value: (transfer none): the #LdDiagramView widget
* assigned to the toolbar.
*/
LdDiagramView *
ld_library_toolbar_get_view (LdLibraryToolbar *self)
{
g_return_val_if_fail (LD_IS_LIBRARY_TOOLBAR (self), NULL);
return self->priv->view;
}
static void
reload_library (LdLibraryToolbar *self)
{
g_return_if_fail (LD_IS_LIBRARY_TOOLBAR (self));
/* Clear the toolbar first, if there was already something in it. */
gtk_container_foreach (GTK_CONTAINER (self),
(GtkCallback) gtk_widget_destroy, NULL);
if (self->priv->library)
{
GSList *categories;
categories = (GSList *) ld_library_get_children (self->priv->library);
g_slist_foreach (categories, load_category_cb, self);
}
}
static void
load_category_cb (gpointer data, gpointer user_data)
{
LdLibraryToolbar *self;
LdSymbolCategory *cat;
const gchar *human_name;
GdkPixbuf *pbuf, *new_pbuf;
GtkWidget *img;
GtkToolItem *item;
GtkWidget *button;
GtkStyle *style;
g_return_if_fail (LD_IS_LIBRARY_TOOLBAR (user_data));
g_return_if_fail (LD_IS_SYMBOL_CATEGORY (data));
self = user_data;
cat = data;
pbuf = gdk_pixbuf_new_from_file_at_size (ld_symbol_category_get_image_path
(cat), LIBRARY_TOOLBAR_ICON_WIDTH, -1, NULL);
g_return_if_fail (pbuf != NULL);
button = gtk_toggle_button_new ();
style = gtk_rc_get_style (button);
/* TODO: Handle all states. */
new_pbuf = recolor_pixbuf (pbuf, &style->fg[GTK_STATE_NORMAL]);
if (new_pbuf)
{
g_object_unref (pbuf);
pbuf = new_pbuf;
}
img = gtk_image_new_from_pixbuf (pbuf);
g_object_unref (pbuf);
item = gtk_tool_item_new ();
gtk_container_add (GTK_CONTAINER (button), img);
gtk_container_add (GTK_CONTAINER (item), button);
/* Don't steal focus from the view. */
g_object_set (button, "can-focus", FALSE, NULL);
/* Assign the category to the toggle button. */
/* TODO: Move this to the data parameter for the signal handler.
* Use g_signal_connect_data() to set up destroy notification.
*/
g_object_ref (cat);
g_object_set_data_full (G_OBJECT (button),
"category", cat, (GDestroyNotify) g_object_unref);
/* Hook toggling of the button. */
g_signal_connect (button, "toggled", G_CALLBACK (on_category_toggle), self);
human_name = ld_symbol_category_get_human_name (cat);
gtk_tool_item_set_tooltip_text (item, human_name);
gtk_toolbar_insert (GTK_TOOLBAR (self), item, 0);
}
static GdkPixbuf *
recolor_pixbuf (GdkPixbuf *pbuf, GdkColor *color)
{
gint width, height;
GdkPixbuf *new_pbuf;
cairo_surface_t *cr_surface;
cairo_t *cr;
width = gdk_pixbuf_get_width (pbuf);
height = gdk_pixbuf_get_height (pbuf);
new_pbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
g_return_val_if_fail (new_pbuf != NULL, NULL);
cr_surface = cairo_image_surface_create_for_data
(gdk_pixbuf_get_pixels (new_pbuf), CAIRO_FORMAT_ARGB32,
width, height, gdk_pixbuf_get_rowstride (new_pbuf));
cr = cairo_create (cr_surface);
/* Change the color of all pixels but leave the alpha channel intact. */
gdk_cairo_set_source_color (cr, color);
cairo_paint (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_DEST_IN);
gdk_cairo_set_source_pixbuf (cr, pbuf, 0, 0);
cairo_paint (cr);
cairo_destroy (cr);
cairo_surface_destroy (cr_surface);
return new_pbuf;
}
static void
redraw_symbol_menu (LdLibraryToolbar *self)
{
SymbolMenuData *data;
g_return_if_fail (LD_IS_LIBRARY_TOOLBAR (self));
data = &self->priv->symbol_menu;
gtk_widget_queue_draw_area (GTK_WIDGET (self->priv->view),
0, data->menu_y - 1, data->menu_width + 2, data->menu_height + 2);
}
static void
emit_symbol_signal (LdLibraryToolbar *self, guint signal_id, gint menu_index)
{
SymbolMenuData *data;
SymbolMenuItem *item;
data = &self->priv->symbol_menu;
if (menu_index == -1)
menu_index = data->active_item;
if (menu_index != -1)
{
item = &data->items[menu_index];
g_signal_emit (self, signal_id, 0, item->symbol, item->klass);
}
}
static void
on_category_toggle (GtkToggleButton *toggle_button, gpointer user_data)
{
LdLibraryToolbar *self;
LdLibraryToolbarPrivate *priv;
LdSymbolCategory *cat;
SymbolMenuData *data;
const gchar *category_name, *symbol_name;
cat = g_object_get_data (G_OBJECT (toggle_button), "category");
self = LD_LIBRARY_TOOLBAR (user_data);
priv = self->priv;
data = &priv->symbol_menu;
/* First untoggle any active button. */
if (data->active_button)
gtk_toggle_button_set_active (data->active_button, FALSE);
/* And toggle signal handlers that enable the user to add a symbol. */
if (data->active_button == toggle_button)
{
gint i;
block_view_handlers (self);
g_object_unref (data->active_button);
data->active_button = NULL;
emit_symbol_signal (self, LD_LIBRARY_TOOLBAR_GET_CLASS (self)
->symbol_deselected_signal, -1);
/* Ashes to ashes, NULL to NULL. */
for (i = 0; i < data->n_items; i++)
{
g_object_unref (data->items[i].symbol);
g_free (data->items[i].klass);
}
g_free (data->items);
data->items = NULL;
gtk_grab_remove (GTK_WIDGET (self->priv->view));
}
else
{
const GSList *children, *symbol_iter;
SymbolMenuItem *item;
gint x, y, menu_width;
g_return_if_fail (gtk_widget_translate_coordinates (GTK_WIDGET
(toggle_button), GTK_WIDGET (priv->view), 0, 0, &x, &y));
data->menu_y = y;
data->menu_height = GTK_WIDGET (toggle_button)->allocation.height;
unblock_view_handlers (self);
data->active_button = toggle_button;
g_object_ref (data->active_button);
category_name = ld_symbol_category_get_name (cat);
children = ld_symbol_category_get_children (cat);
data->n_items = g_slist_length ((GSList *) children);
data->items = g_new (SymbolMenuItem, data->n_items);
data->active_item = -1;
item = data->items;
menu_width = 0;
for (symbol_iter = children; symbol_iter;
symbol_iter = symbol_iter->next)
{
LdRectangle area;
item->symbol = LD_SYMBOL (symbol_iter->data);
g_object_ref (item->symbol);
symbol_name = ld_symbol_get_name (item->symbol);
item->klass = g_build_path (LD_LIBRARY_IDENTIFIER_SEPARATOR,
category_name, symbol_name, NULL);
ld_symbol_get_area (item->symbol, &area);
/* This is the height when the center of the symbol is
* in the center of it's symbol menu item.
*/
item->scale = data->menu_height * 0.5
/ MAX (ABS (area.y), ABS (area.y + area.height)) * 0.5;
if (item->scale * area.width > 1.5 * data->menu_height)
item->scale = 1.5 * data->menu_height / area.width;
item->width = data->menu_height * 0.5 + item->scale * area.width;
item->dx = item->width * 0.5 + item->scale
* (area.width * 0.5 - ABS (area.x + area.width));
menu_width += item++->width;
}
data->menu_width = menu_width;
gtk_grab_add (GTK_WIDGET (self->priv->view));
}
redraw_symbol_menu (self);
}
#define DEFINE_VIEW_HANDLER_FUNC(name) \
static inline void \
name ## _view_handlers (LdLibraryToolbar *self) \
{ \
gint i; \
g_return_if_fail (LD_IS_DIAGRAM_VIEW (self->priv->view)); \
for (i = 0; i < VIEW_HANDLER_COUNT; i++) \
g_signal_handler_ ## name (self->priv->view, \
self->priv->view_handlers[i]); \
}
DEFINE_VIEW_HANDLER_FUNC (block)
DEFINE_VIEW_HANDLER_FUNC (unblock)
DEFINE_VIEW_HANDLER_FUNC (disconnect)
static gboolean
on_view_exposed (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
{
cairo_t *cr;
LdLibraryToolbar *self;
SymbolMenuData *data;
gint i, x;
cr = gdk_cairo_create (widget->window);
self = LD_LIBRARY_TOOLBAR (user_data);
data = &self->priv->symbol_menu;
/* Draw some border. */
cairo_set_line_width (cr, 1);
cairo_rectangle (cr, 0, data->menu_y, data->menu_width, data->menu_height);
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_fill (cr);
/* Draw all symbols from that category. */
for (x = i = 0; i < data->n_items; i++)
{
SymbolMenuItem *item;
if (i)
{
cairo_move_to (cr, x - 0.5, data->menu_y + 1);
cairo_line_to (cr, x - 0.5, data->menu_y + data->menu_height);
cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
cairo_stroke (cr);
}
item = data->items + i;
cairo_save (cr);
cairo_rectangle (cr, x, data->menu_y, item->width, data->menu_height);
cairo_clip (cr);
if (i == data->active_item)
{
cairo_set_source_rgb (cr, 0.9, 0.9, 0.9);
cairo_paint (cr);
}
cairo_translate (cr, x + item->dx,
data->menu_y + data->menu_height * 0.5);
cairo_scale (cr, item->scale, item->scale);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_set_line_width (cr, 1 / item->scale);
ld_symbol_draw (item->symbol, cr);
cairo_restore (cr);
x += item->width;
}
cairo_rectangle (cr, 0.5, data->menu_y + 0.5,
data->menu_width, data->menu_height);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_stroke (cr);
cairo_destroy (cr);
return FALSE;
}
static gboolean
on_view_motion_notify (GtkWidget *widget, GdkEventMotion *event,
gpointer user_data)
{
LdLibraryToolbar *self;
SymbolMenuData *data;
gint i, x, at_cursor = -1;
self = LD_LIBRARY_TOOLBAR (user_data);
data = &self->priv->symbol_menu;
if (widget->window != event->window
|| event->x < 0 || event->y < data->menu_y
|| event->y >= data->menu_y + data->menu_height)
goto on_view_motion_notify_end;
for (x = i = 0; i < data->n_items; i++)
{
x += data->items[i].width;
if (event->x < x)
{
at_cursor = i;
break;
}
}
on_view_motion_notify_end:
if (data->active_item != at_cursor)
{
emit_symbol_signal (self, LD_LIBRARY_TOOLBAR_GET_CLASS (self)
->symbol_deselected_signal, -1);
if (at_cursor != -1)
emit_symbol_signal (self, LD_LIBRARY_TOOLBAR_GET_CLASS (self)
->symbol_selected_signal, at_cursor);
}
data->active_item = at_cursor;
redraw_symbol_menu (self);
return FALSE;
}
static gboolean
on_view_button_press (GtkWidget *widget, GdkEventButton *event,
gpointer user_data)
{
LdLibraryToolbar *self;
SymbolMenuData *data;
self = LD_LIBRARY_TOOLBAR (user_data);
data = &self->priv->symbol_menu;
/* If the event occured elsewhere, cancel the menu and put the event
* back into the queue.
*/
if (widget->window != event->window && data->active_button)
{
gtk_toggle_button_set_active (data->active_button, FALSE);
gdk_event_put ((GdkEvent *) event);
}
return FALSE;
}
static gboolean
on_view_button_release (GtkWidget *widget, GdkEventButton *event,
gpointer user_data)
{
LdLibraryToolbar *self;
SymbolMenuData *data;
self = LD_LIBRARY_TOOLBAR (user_data);
data = &self->priv->symbol_menu;
if (event->button != 1)
return FALSE;
emit_symbol_signal (self, LD_LIBRARY_TOOLBAR_GET_CLASS (self)
->symbol_chosen_signal, -1);
/* We've either chosen a symbol or canceled the menu, so hide it. */
if (data->active_button)
gtk_toggle_button_set_active (data->active_button, FALSE);
return FALSE;
}

View File

@ -0,0 +1,69 @@
/*
* ld-library-toolbar.h
*
* This file is a part of logdiag.
* Copyright Přemysl Janouch 2011. All rights reserved.
*
* See the file LICENSE for licensing information.
*
*/
#ifndef __LD_LIBRARY_TOOLBAR_H__
#define __LD_LIBRARY_TOOLBAR_H__
G_BEGIN_DECLS
#define LD_TYPE_LIBRARY_TOOLBAR (ld_library_toolbar_get_type ())
#define LD_LIBRARY_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST \
((obj), LD_TYPE_LIBRARY_TOOLBAR, LdLibraryToolbar))
#define LD_LIBRARY_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
((klass), LD_TYPE_LIBRARY_TOOLBAR, LdLibraryToolbarClass))
#define LD_IS_LIBRARY_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
((obj), LD_TYPE_LIBRARY_TOOLBAR))
#define LD_IS_LIBRARY_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
((klass), LD_TYPE_LIBRARY_TOOLBAR))
#define LD_LIBRARY_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
((obj), LD_LIBRARY_TOOLBAR, LdLibraryToolbarClass))
typedef struct _LdLibraryToolbar LdLibraryToolbar;
typedef struct _LdLibraryToolbarPrivate LdLibraryToolbarPrivate;
typedef struct _LdLibraryToolbarClass LdLibraryToolbarClass;
/**
* LdLibraryToolbar:
*/
struct _LdLibraryToolbar
{
/*< private >*/
GtkToolbar parent_instance;
LdLibraryToolbarPrivate *priv;
};
struct _LdLibraryToolbarClass
{
/*< private >*/
GtkToolbarClass parent_class;
guint symbol_chosen_signal;
guint symbol_selected_signal;
guint symbol_deselected_signal;
};
GType ld_library_toolbar_get_type (void) G_GNUC_CONST;
GtkWidget *ld_library_toolbar_new (void);
void ld_library_toolbar_set_library (LdLibraryToolbar *self,
LdLibrary *library);
LdLibrary *ld_library_toolbar_get_library (LdLibraryToolbar *self);
void ld_library_toolbar_set_view (LdLibraryToolbar *self,
LdDiagramView *view);
LdDiagramView *ld_library_toolbar_get_view (LdLibraryToolbar *self);
G_END_DECLS
#endif /* ! __LD_LIBRARY_TOOLBAR_H__ */

View File

@ -2,7 +2,7 @@
* ld-library.c * ld-library.c
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011, 2012 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -17,30 +17,28 @@
/** /**
* SECTION:ld-library * SECTION:ld-library
* @short_description: A symbol library * @short_description: A symbol library
* @see_also: #LdSymbol, #LdCategory * @see_also: #LdSymbol, #LdSymbolCategory
* *
* #LdLibrary is used for loading symbols from their files. The library object * #LdLibrary is used for loading symbols from their files.
* itself is a container for categories, which in turn contain other
* subcategories and the actual symbols.
*/ */
/* /*
* LdLibraryPrivate: * LdLibraryPrivate:
* @lua: state of the scripting language. * @lua: state of the scripting language.
* @children: categories in the library. * @children: child objects of the library.
*/ */
struct _LdLibraryPrivate struct _LdLibraryPrivate
{ {
LdLua *lua; LdLua *lua;
LdCategory *root; GSList *children;
}; };
static void ld_library_finalize (GObject *gobject); static void ld_library_finalize (GObject *gobject);
static LdCategory *load_category (LdLibrary *self, static LdSymbolCategory *load_category (LdLibrary *self,
const gchar *path, const gchar *name); const gchar *path, const gchar *name);
static gboolean load_category_cb (const gchar *base, static gboolean load_category_cb (const gchar *base,
const gchar *path, gpointer userdata); const gchar *filename, gpointer userdata);
static void load_category_symbol_cb (LdSymbol *symbol, gpointer user_data); static void load_category_symbol_cb (LdSymbol *symbol, gpointer user_data);
static gchar *read_human_name_from_file (const gchar *filename); static gchar *read_human_name_from_file (const gchar *filename);
@ -48,11 +46,11 @@ static gchar *read_human_name_from_file (const gchar *filename);
static gboolean foreach_dir (const gchar *path, static gboolean foreach_dir (const gchar *path,
gboolean (*callback) (const gchar *, const gchar *, gpointer), gboolean (*callback) (const gchar *, const gchar *, gpointer),
gpointer userdata, GError **error); gpointer userdata, GError **error);
static gboolean ld_library_load_cb
static LdSymbol *traverse_path (LdCategory *category, gchar **path); (const gchar *base, const gchar *filename, gpointer userdata);
G_DEFINE_TYPE (LdLibrary, ld_library, G_TYPE_OBJECT) G_DEFINE_TYPE (LdLibrary, ld_library, G_TYPE_OBJECT);
static void static void
ld_library_class_init (LdLibraryClass *klass) ld_library_class_init (LdLibraryClass *klass)
@ -83,7 +81,7 @@ ld_library_init (LdLibrary *self)
(self, LD_TYPE_LIBRARY, LdLibraryPrivate); (self, LD_TYPE_LIBRARY, LdLibraryPrivate);
self->priv->lua = ld_lua_new (); self->priv->lua = ld_lua_new ();
self->priv->root = ld_category_new (LD_LIBRARY_IDENTIFIER_SEPARATOR, "/"); self->priv->children = NULL;
} }
static void static void
@ -94,7 +92,9 @@ ld_library_finalize (GObject *gobject)
self = LD_LIBRARY (gobject); self = LD_LIBRARY (gobject);
g_object_unref (self->priv->lua); g_object_unref (self->priv->lua);
g_object_unref (self->priv->root);
g_slist_foreach (self->priv->children, (GFunc) g_object_unref, NULL);
g_slist_free (self->priv->children);
/* Chain up to the parent class. */ /* Chain up to the parent class. */
G_OBJECT_CLASS (ld_library_parent_class)->finalize (gobject); G_OBJECT_CLASS (ld_library_parent_class)->finalize (gobject);
@ -152,9 +152,7 @@ foreach_dir (const gchar *path,
typedef struct typedef struct
{ {
LdLibrary *self; LdLibrary *self;
LdCategory *cat; LdSymbolCategory *cat;
guint changed : 1;
guint load_symbols : 1;
} }
LoadCategoryData; LoadCategoryData;
@ -166,10 +164,12 @@ LoadCategoryData;
* *
* Loads a category into the library. * Loads a category into the library.
*/ */
static LdCategory * static LdSymbolCategory *
load_category (LdLibrary *self, const gchar *path, const gchar *name) load_category (LdLibrary *self, const gchar *path, const gchar *name)
{ {
gchar *category_file, *human_name; LdSymbolCategory *cat;
gchar *icon_file, *category_file;
gchar *human_name;
LoadCategoryData data; LoadCategoryData data;
g_return_val_if_fail (LD_IS_LIBRARY (self), NULL); g_return_val_if_fail (LD_IS_LIBRARY (self), NULL);
@ -177,59 +177,57 @@ load_category (LdLibrary *self, const gchar *path, const gchar *name)
g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (name != NULL, NULL);
if (!g_file_test (path, G_FILE_TEST_IS_DIR)) if (!g_file_test (path, G_FILE_TEST_IS_DIR))
return NULL; goto load_category_fail_1;
icon_file = g_build_filename (path, "icon.svg", NULL);
if (!g_file_test (icon_file, G_FILE_TEST_IS_REGULAR))
{
g_warning ("the category in `%s' has no icon", path);
goto load_category_fail_2;
}
category_file = g_build_filename (path, "category.json", NULL); category_file = g_build_filename (path, "category.json", NULL);
human_name = read_human_name_from_file (category_file); human_name = read_human_name_from_file (category_file);
if (!human_name) if (!human_name)
human_name = g_strdup (name); human_name = g_strdup (name);
cat = ld_symbol_category_new (name, human_name);
ld_symbol_category_set_image_path (cat, icon_file);
data.self = self; data.self = self;
data.cat = ld_category_new (name, human_name); data.cat = cat;
data.load_symbols = TRUE;
data.changed = FALSE;
foreach_dir (path, load_category_cb, &data, NULL); foreach_dir (path, load_category_cb, &data, NULL);
g_free (human_name); g_free (human_name);
g_free (category_file); g_free (category_file);
return data.cat; g_free (icon_file);
return cat;
load_category_fail_2:
g_free (icon_file);
load_category_fail_1:
return NULL;
} }
/* /*
* load_category_cb: * load_category_cb:
* *
* Load contents of a directory into a symbol category. * Load script files from a directory into a symbol category.
*/ */
static gboolean static gboolean
load_category_cb (const gchar *base, const gchar *path, gpointer userdata) load_category_cb (const gchar *base, const gchar *filename, gpointer userdata)
{ {
LoadCategoryData *data; LoadCategoryData *data;
g_return_val_if_fail (base != NULL, FALSE); g_return_val_if_fail (base != NULL, FALSE);
g_return_val_if_fail (path != NULL, FALSE); g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (userdata != NULL, FALSE); g_return_val_if_fail (userdata != NULL, FALSE);
data = (LoadCategoryData *) userdata; data = (LoadCategoryData *) userdata;
if (g_file_test (path, G_FILE_TEST_IS_DIR)) if (ld_lua_check_file (data->self->priv->lua, filename))
{ ld_lua_load_file (data->self->priv->lua, filename,
LdCategory *cat;
cat = load_category (data->self, path, base);
if (cat)
{
ld_category_add_child (data->cat, cat);
g_object_unref (cat);
}
}
else if (data->load_symbols
&& ld_lua_check_file (data->self->priv->lua, path))
{
ld_lua_load_file (data->self->priv->lua, path,
load_category_symbol_cb, data->cat); load_category_symbol_cb, data->cat);
}
data->changed = TRUE;
return TRUE; return TRUE;
} }
@ -241,13 +239,30 @@ load_category_cb (const gchar *base, const gchar *path, gpointer userdata)
static void static void
load_category_symbol_cb (LdSymbol *symbol, gpointer user_data) load_category_symbol_cb (LdSymbol *symbol, gpointer user_data)
{ {
LdCategory *cat; const gchar *name;
LdSymbolCategory *cat;
const GSList *children, *iter;
g_return_if_fail (LD_IS_SYMBOL (symbol)); g_return_if_fail (LD_IS_SYMBOL (symbol));
g_return_if_fail (LD_IS_CATEGORY (user_data)); g_return_if_fail (LD_IS_SYMBOL_CATEGORY (user_data));
cat = LD_CATEGORY (user_data); cat = LD_SYMBOL_CATEGORY (user_data);
ld_category_insert_symbol (cat, symbol, -1); name = ld_symbol_get_name (symbol);
/* Check for name collisions with other symbols. */
children = ld_symbol_category_get_children (cat);
for (iter = children; iter; iter = iter->next)
{
if (!LD_IS_SYMBOL (iter->data))
continue;
if (!strcmp (name, ld_symbol_get_name (LD_SYMBOL (iter->data))))
{
g_warning ("attempted to insert multiple `%s' symbols into"
" category `%s'", name, ld_symbol_category_get_name (cat));
return;
}
}
ld_symbol_category_insert_child (cat, G_OBJECT (symbol), -1);
} }
/* /*
@ -308,6 +323,18 @@ read_human_name_from_file_end:
return NULL; return NULL;
} }
/*
* LibraryLoadData:
*
* Data shared between ld_library_load() and ld_library_load_cb().
*/
typedef struct
{
LdLibrary *self;
gboolean changed;
}
LibraryLoadData;
/** /**
* ld_library_load: * ld_library_load:
* @self: an #LdLibrary object. * @self: an #LdLibrary object.
@ -318,34 +345,46 @@ read_human_name_from_file_end:
gboolean gboolean
ld_library_load (LdLibrary *self, const gchar *directory) ld_library_load (LdLibrary *self, const gchar *directory)
{ {
LoadCategoryData data; LibraryLoadData data;
g_return_val_if_fail (LD_IS_LIBRARY (self), FALSE); g_return_val_if_fail (LD_IS_LIBRARY (self), FALSE);
g_return_val_if_fail (directory != NULL, FALSE); g_return_val_if_fail (directory != NULL, FALSE);
/* Almost like load_category(). */
data.self = self; data.self = self;
data.cat = self->priv->root;
data.load_symbols = FALSE;
data.changed = FALSE; data.changed = FALSE;
foreach_dir (directory, load_category_cb, &data, NULL); foreach_dir (directory, ld_library_load_cb, &data, NULL);
/* XXX: It might also make sense to just forward the "children-changed"
* signal of the root category but we'd have to block it here anyway,
* so that we don't unnecessarily fire events for every single change.
*
* The user code isn't supposed to make changes to / and it's its own
* problem if it keeps reloading something a hundred times in a row.
*
* That said, it'd be possible to add change grouping methods to
* LdCategory and so delay the signal emission until an `unblock'.
*/
if (data.changed) if (data.changed)
g_signal_emit (self, LD_LIBRARY_GET_CLASS (self)->changed_signal, 0); g_signal_emit (self, LD_LIBRARY_GET_CLASS (self)->changed_signal, 0);
return TRUE; return TRUE;
} }
/*
* ld_library_load_cb:
*
* A callback that's called for each file in the root directory.
*/
static gboolean
ld_library_load_cb (const gchar *base, const gchar *filename, gpointer userdata)
{
LdSymbolCategory *cat;
LibraryLoadData *data;
g_return_val_if_fail (base != NULL, FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (userdata != NULL, FALSE);
data = (LibraryLoadData *) userdata;
cat = load_category (data->self, filename, base);
if (cat)
ld_library_insert_child (data->self, G_OBJECT (cat), -1);
data->changed = TRUE;
return TRUE;
}
/** /**
* ld_library_find_symbol: * ld_library_find_symbol:
* @self: an #LdLibrary object. * @self: an #LdLibrary object.
@ -355,66 +394,131 @@ ld_library_load (LdLibrary *self, const gchar *directory)
* *
* Return value: a symbol object if found, %NULL otherwise. * Return value: a symbol object if found, %NULL otherwise.
*/ */
/* XXX: With this level of indentation, this function is really ugly. */
LdSymbol * LdSymbol *
ld_library_find_symbol (LdLibrary *self, const gchar *identifier) ld_library_find_symbol (LdLibrary *self, const gchar *identifier)
{ {
gchar **path; gchar **id_el_start, **id_el;
LdSymbol *symbol = NULL; const GSList *list, *list_el;
g_return_val_if_fail (LD_IS_LIBRARY (self), NULL); g_return_val_if_fail (LD_IS_LIBRARY (self), NULL);
g_return_val_if_fail (identifier != NULL, NULL); g_return_val_if_fail (identifier != NULL, NULL);
path = g_strsplit (identifier, LD_LIBRARY_IDENTIFIER_SEPARATOR, 0); id_el_start = g_strsplit (identifier, LD_LIBRARY_IDENTIFIER_SEPARATOR, 0);
if (path) if (!id_el_start)
{ return NULL;
symbol = traverse_path (self->priv->root, path);
g_strfreev (path);
}
return symbol;
}
static LdSymbol * list = ld_library_get_children (self);
traverse_path (LdCategory *category, gchar **path) for (id_el = id_el_start; id_el[0]; id_el++)
{ {
const GSList *list, *iter; LdSymbolCategory *cat;
LdSymbol *symbol; LdSymbol *symbol;
gboolean found = FALSE;
g_return_val_if_fail (*path != NULL, NULL); for (list_el = list; list_el; list_el = g_slist_next (list_el))
{
/* If the current identifier element is a category (not last)
* and this list element is a category.
*/
if (id_el[1] && LD_IS_SYMBOL_CATEGORY (list_el->data))
{
cat = LD_SYMBOL_CATEGORY (list_el->data);
if (strcmp (id_el[0], ld_symbol_category_get_name (cat)))
continue;
/* Walk the category tree to where the symbol is supposed to be. */ list = ld_symbol_category_get_children (cat);
for (; path[1]; path++) found = TRUE;
{
list = ld_category_get_children (category);
for (iter = list; iter; iter = g_slist_next (iter))
{
category = LD_CATEGORY (iter->data);
if (!strcmp (*path, ld_category_get_name (category)))
break; break;
} }
if (!iter) /* If the current identifier element is a symbol (last)
return NULL; * and this list element is a symbol.
} */
else if (!id_el[1] && LD_IS_SYMBOL (list_el->data))
/* And look up the actual symbol at the leaf. */
list = ld_category_get_symbols (category);
for (iter = list; iter; iter = g_slist_next (iter))
{ {
symbol = LD_SYMBOL (iter->data); symbol = LD_SYMBOL (list_el->data);
if (!strcmp (*path, ld_symbol_get_name (symbol))) if (strcmp (id_el[0], ld_symbol_get_name (symbol)))
continue;
g_strfreev (id_el_start);
return symbol; return symbol;
} }
}
if (!found)
break;
}
g_strfreev (id_el_start);
return NULL; return NULL;
} }
/** /**
* ld_library_get_root: * ld_library_clear:
* @self: an #LdLibrary object. * @self: an #LdLibrary object.
* *
* Return value: (transfer none): the root category. Do not modify. * Clear all the contents.
*/ */
LdCategory * void
ld_library_get_root (LdLibrary *self) ld_library_clear (LdLibrary *self)
{
g_return_if_fail (LD_IS_LIBRARY (self));
g_slist_foreach (self->priv->children, (GFunc) g_object_unref, NULL);
g_slist_free (self->priv->children);
self->priv->children = NULL;
g_signal_emit (self,
LD_LIBRARY_GET_CLASS (self)->changed_signal, 0);
}
/**
* ld_library_insert_child:
* @self: an #LdLibrary object.
* @child: the child to be inserted.
* @pos: the position at which the child will be inserted.
* Negative values will append to the end of list.
*
* Insert a child into the library.
*/
void
ld_library_insert_child (LdLibrary *self, GObject *child, gint pos)
{
g_return_if_fail (LD_IS_LIBRARY (self));
g_return_if_fail (G_IS_OBJECT (child));
g_object_ref (child);
self->priv->children = g_slist_insert (self->priv->children, child, pos);
}
/**
* ld_library_remove_child:
* @self: an #LdLibrary object.
* @child: the child to be removed.
*
* Remove a child from the library.
*/
void
ld_library_remove_child (LdLibrary *self, GObject *child)
{
g_return_if_fail (LD_IS_LIBRARY (self));
g_return_if_fail (G_IS_OBJECT (child));
if (g_slist_find (self->priv->children, child))
{
g_object_unref (child);
self->priv->children = g_slist_remove (self->priv->children, child);
}
}
/**
* ld_library_get_children:
* @self: an #LdLibrary object.
*
* Return value: (element-type GObject): a list of children. Do not modify.
*/
const GSList *
ld_library_get_children (LdLibrary *self)
{ {
g_return_val_if_fail (LD_IS_LIBRARY (self), NULL); g_return_val_if_fail (LD_IS_LIBRARY (self), NULL);
return self->priv->root; return self->priv->children;
} }

View File

@ -2,7 +2,7 @@
* ld-library.h * ld-library.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2012 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -15,15 +15,16 @@ G_BEGIN_DECLS
#define LD_TYPE_LIBRARY (ld_library_get_type ()) #define LD_TYPE_LIBRARY (ld_library_get_type ())
#define LD_LIBRARY(obj) \ #define LD_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_CAST \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_LIBRARY, LdLibrary)) ((obj), LD_TYPE_LIBRARY, LdLibrary))
#define LD_LIBRARY_CLASS(klass) \ #define LD_LIBRARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_LIBRARY, LdLibraryClass)) ((klass), LD_TYPE_LIBRARY, LdLibraryClass))
#define LD_IS_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_LIBRARY)) #define LD_IS_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
#define LD_IS_LIBRARY_CLASS(klass) \ ((obj), LD_TYPE_LIBRARY))
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_LIBRARY)) #define LD_IS_LIBRARY_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
#define LD_LIBRARY_GET_CLASS(obj) \ ((klass), LD_TYPE_LIBRARY))
(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_LIBRARY, LdLibraryClass)) #define LD_LIBRARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
((obj), LD_LIBRARY, LdLibraryClass))
typedef struct _LdLibrary LdLibrary; typedef struct _LdLibrary LdLibrary;
typedef struct _LdLibraryPrivate LdLibraryPrivate; typedef struct _LdLibraryPrivate LdLibraryPrivate;
@ -59,9 +60,14 @@ GType ld_library_get_type (void) G_GNUC_CONST;
LdLibrary *ld_library_new (void); LdLibrary *ld_library_new (void);
gboolean ld_library_load (LdLibrary *self, const gchar *directory); gboolean ld_library_load (LdLibrary *self, const gchar *directory);
LdSymbol *ld_library_find_symbol (LdLibrary *self, const gchar *identifier); LdSymbol *ld_library_find_symbol (LdLibrary *self, const gchar *identifier);
LdCategory *ld_library_get_root (LdLibrary *self); void ld_library_clear (LdLibrary *self);
void ld_library_insert_child (LdLibrary *self, GObject *child, gint pos);
void ld_library_remove_child (LdLibrary *self, GObject *child);
const GSList *ld_library_get_children (LdLibrary *self);
G_END_DECLS G_END_DECLS
#endif /* ! __LD_LIBRARY_H__ */ #endif /* ! __LD_LIBRARY_H__ */

View File

@ -2,7 +2,7 @@
* ld-lua-private.h * ld-lua-private.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -23,3 +23,4 @@ void ld_lua_private_draw (LdLua *self, LdLuaSymbol *symbol, cairo_t *cr);
G_END_DECLS G_END_DECLS
#endif /* ! __LD_LUA_PRIVATE_H__ */ #endif /* ! __LD_LUA_PRIVATE_H__ */

View File

@ -2,7 +2,7 @@
* ld-lua-symbol-private.h * ld-lua-symbol-private.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -37,3 +37,4 @@ struct _LdLuaSymbolPrivate
G_END_DECLS G_END_DECLS
#endif /* ! __LD_LUA_SYMBOL_PRIVATE_H__ */ #endif /* ! __LD_LUA_SYMBOL_PRIVATE_H__ */

View File

@ -2,7 +2,7 @@
* ld-lua-symbol.c * ld-lua-symbol.c
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -32,7 +32,7 @@ static const LdPointArray *ld_lua_symbol_real_get_terminals (LdSymbol *symbol);
static void ld_lua_symbol_real_draw (LdSymbol *symbol, cairo_t *cr); static void ld_lua_symbol_real_draw (LdSymbol *symbol, cairo_t *cr);
G_DEFINE_TYPE (LdLuaSymbol, ld_lua_symbol, LD_TYPE_SYMBOL) G_DEFINE_TYPE (LdLuaSymbol, ld_lua_symbol, LD_TYPE_SYMBOL);
static void static void
ld_lua_symbol_class_init (LdLuaSymbolClass *klass) ld_lua_symbol_class_init (LdLuaSymbolClass *klass)
@ -135,3 +135,4 @@ ld_lua_symbol_real_draw (LdSymbol *symbol, cairo_t *cr)
ld_lua_private_draw (self->priv->lua, self, cr); ld_lua_private_draw (self->priv->lua, self, cr);
cairo_restore (cr); cairo_restore (cr);
} }

View File

@ -2,7 +2,7 @@
* ld-lua-symbol.h * ld-lua-symbol.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -15,16 +15,16 @@ G_BEGIN_DECLS
#define LD_TYPE_LUA_SYMBOL (ld_lua_symbol_get_type ()) #define LD_TYPE_LUA_SYMBOL (ld_lua_symbol_get_type ())
#define LD_LUA_SYMBOL(obj) \ #define LD_LUA_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_LUA_SYMBOL, LdLuaSymbol)) ((obj), LD_TYPE_LUA_SYMBOL, LdLuaSymbol))
#define LD_LUA_SYMBOL_CLASS(klass) \ #define LD_LUA_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_LUA_SYMBOL, LdLuaSymbolClass)) ((klass), LD_TYPE_LUA_SYMBOL, LdLuaSymbolClass))
#define LD_IS_LUA_SYMBOL(obj) \ #define LD_IS_LUA_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_LUA_SYMBOL)) ((obj), LD_TYPE_LUA_SYMBOL))
#define LD_IS_LUA_SYMBOL_CLASS(klass) \ #define LD_IS_LUA_SYMBOL_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_LUA_SYMBOL)) ((klass), LD_TYPE_LUA_SYMBOL))
#define LD_LUA_SYMBOL_GET_CLASS(obj) \ #define LD_LUA_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_LUA_SYMBOL, LdLuaSymbolClass)) ((obj), LD_LUA_SYMBOL, LdLuaSymbolClass))
typedef struct _LdLuaSymbol LdLuaSymbol; typedef struct _LdLuaSymbol LdLuaSymbol;
typedef struct _LdLuaSymbolPrivate LdLuaSymbolPrivate; typedef struct _LdLuaSymbolPrivate LdLuaSymbolPrivate;
@ -57,3 +57,4 @@ GType ld_lua_symbol_get_type (void) G_GNUC_CONST;
G_END_DECLS G_END_DECLS
#endif /* ! __LD_LUA_SYMBOL_H__ */ #endif /* ! __LD_LUA_SYMBOL_H__ */

View File

@ -2,7 +2,7 @@
* ld-lua.c * ld-lua.c
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011, 2012 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -47,7 +47,6 @@ struct _LdLuaPrivate
#define LD_LUA_LIBRARY_NAME "logdiag" #define LD_LUA_LIBRARY_NAME "logdiag"
#define LD_LUA_DATA_INDEX LD_LUA_LIBRARY_NAME "_data" #define LD_LUA_DATA_INDEX LD_LUA_LIBRARY_NAME "_data"
#define LD_LUA_SYMBOLS_INDEX LD_LUA_LIBRARY_NAME "_symbols" #define LD_LUA_SYMBOLS_INDEX LD_LUA_LIBRARY_NAME "_symbols"
#define LD_LUA_META_INDEX LD_LUA_LIBRARY_NAME "_meta"
/* /*
* LdLuaData: * LdLuaData:
@ -89,6 +88,7 @@ static gboolean read_symbol_area (lua_State *L, int index, LdRectangle *area);
static gboolean read_terminals (lua_State *L, int index, static gboolean read_terminals (lua_State *L, int index,
LdPointArray **terminals); LdPointArray **terminals);
static void push_cairo_object (lua_State *L, LdLuaDrawData *draw_data);
static gdouble get_cairo_scale (cairo_t *cr); static gdouble get_cairo_scale (cairo_t *cr);
static int ld_lua_cairo_save (lua_State *L); static int ld_lua_cairo_save (lua_State *L);
static int ld_lua_cairo_restore (lua_State *L); static int ld_lua_cairo_restore (lua_State *L);
@ -150,7 +150,7 @@ static luaL_Reg ld_lua_cairo_table[] =
/* ===== Generic =========================================================== */ /* ===== Generic =========================================================== */
G_DEFINE_TYPE (LdLua, ld_lua, G_TYPE_OBJECT) G_DEFINE_TYPE (LdLua, ld_lua, G_TYPE_OBJECT);
static void static void
ld_lua_class_init (LdLuaClass *klass) ld_lua_class_init (LdLuaClass *klass)
@ -163,49 +163,35 @@ ld_lua_class_init (LdLuaClass *klass)
g_type_class_add_private (klass, sizeof (LdLuaPrivate)); g_type_class_add_private (klass, sizeof (LdLuaPrivate));
} }
static void
push_cairo_metatable (lua_State *L)
{
luaL_Reg *fn;
luaL_newmetatable (L, LD_LUA_META_INDEX);
/* Create a method table. */
lua_newtable (L);
for (fn = ld_lua_cairo_table; fn->name; fn++)
{
lua_pushcfunction (L, fn->func);
lua_setfield (L, -2, fn->name);
}
lua_setfield (L, -2, "__index");
}
static void static void
ld_lua_init (LdLua *self) ld_lua_init (LdLua *self)
{ {
lua_State *L; lua_State *L;
LdLuaData *ud; LdLuaData *ud;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, LD_TYPE_LUA, LdLuaPrivate); self->priv = G_TYPE_INSTANCE_GET_PRIVATE
(self, LD_TYPE_LUA, LdLuaPrivate);
L = self->priv->L = lua_newstate (ld_lua_alloc, NULL); L = self->priv->L = lua_newstate (ld_lua_alloc, NULL);
g_return_if_fail (L != NULL); g_return_if_fail (L != NULL);
/* XXX: Might not be a bad idea to use lua_atpanic(). */ /* TODO: lua_atpanic () */
/* Load some safe libraries. */ /* Load some safe libraries. */
luaL_requiref (L, "string", luaopen_string, TRUE); lua_pushcfunction (L, luaopen_string);
luaL_requiref (L, "table", luaopen_table, TRUE); lua_call (L, 0, 0);
luaL_requiref (L, "math", luaopen_math, TRUE);
lua_pop (L, 3); lua_pushcfunction (L, luaopen_table);
lua_call (L, 0, 0);
lua_pushcfunction (L, luaopen_math);
lua_call (L, 0, 0);
/* Load the application library. */ /* Load the application library. */
luaL_newlib (L, ld_lua_logdiag_lib); luaL_register (L, LD_LUA_LIBRARY_NAME, ld_lua_logdiag_lib);
lua_setglobal (L, LD_LUA_LIBRARY_NAME);
/* Store user data to the registry. */ /* Store user data to the registry. */
ud = lua_newuserdata (L, sizeof *ud); ud = lua_newuserdata (L, sizeof (LdLuaData));
ud->self = self; ud->self = self;
ud->load_callback = NULL; ud->load_callback = NULL;
ud->load_user_data = NULL; ud->load_user_data = NULL;
@ -215,8 +201,6 @@ ld_lua_init (LdLua *self)
/* Create an empty symbol table. */ /* Create an empty symbol table. */
lua_newtable (L); lua_newtable (L);
lua_setfield (L, LUA_REGISTRYINDEX, LD_LUA_SYMBOLS_INDEX); lua_setfield (L, LUA_REGISTRYINDEX, LD_LUA_SYMBOLS_INDEX);
push_cairo_metatable (L);
} }
static void static void
@ -250,6 +234,7 @@ ld_lua_alloc (void *ud, void *ptr, size_t osize, size_t nsize)
g_free (ptr); g_free (ptr);
return NULL; return NULL;
} }
else
return g_try_realloc (ptr, nsize); return g_try_realloc (ptr, nsize);
} }
@ -293,7 +278,7 @@ ld_lua_load_file (LdLua *self, const gchar *filename,
g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (callback != NULL, FALSE); g_return_val_if_fail (callback != NULL, FALSE);
/* XXX: If something from the following fails, Lua will panic. */ /* XXX: If something from the following fails, Lua will call exit(). */
lua_getfield (self->priv->L, LUA_REGISTRYINDEX, LD_LUA_DATA_INDEX); lua_getfield (self->priv->L, LUA_REGISTRYINDEX, LD_LUA_DATA_INDEX);
ud = lua_touserdata (self->priv->L, -1); ud = lua_touserdata (self->priv->L, -1);
lua_pop (self->priv->L, 1); lua_pop (self->priv->L, 1);
@ -346,9 +331,7 @@ ld_lua_private_draw (LdLua *self, LdLuaSymbol *symbol, cairo_t *cr)
data.cr = cr; data.cr = cr;
data.save_count = 0; data.save_count = 0;
lua_pushcfunction (self->priv->L, ld_lua_private_draw_cb); if (lua_cpcall (self->priv->L, ld_lua_private_draw_cb, &data))
lua_pushlightuserdata (self->priv->L, &data);
if (lua_pcall (self->priv->L, 1, 0, 0))
{ {
g_warning ("Lua error: %s", lua_tostring (self->priv->L, -1)); g_warning ("Lua error: %s", lua_tostring (self->priv->L, -1));
lua_pop (self->priv->L, 1); lua_pop (self->priv->L, 1);
@ -361,7 +344,7 @@ ld_lua_private_draw (LdLua *self, LdLuaSymbol *symbol, cairo_t *cr)
static int static int
ld_lua_private_draw_cb (lua_State *L) ld_lua_private_draw_cb (lua_State *L)
{ {
LdLuaDrawData *data, *luadata; LdLuaDrawData *data;
data = lua_touserdata (L, -1); data = lua_touserdata (L, -1);
@ -374,28 +357,9 @@ ld_lua_private_draw_cb (lua_State *L)
lua_getfield (L, -1, "render"); lua_getfield (L, -1, "render");
luaL_checktype (L, -1, LUA_TFUNCTION); luaL_checktype (L, -1, LUA_TFUNCTION);
/* Create a Cairo wrapper object. */ /* Call the function do draw the symbol. */
luadata = lua_newuserdata (L, sizeof *data); push_cairo_object (L, data);
memcpy (luadata, data, sizeof *data); lua_pcall (L, 1, 0, 0);
lua_getfield (L, LUA_REGISTRYINDEX, LD_LUA_META_INDEX);
lua_setmetatable (L, -2);
/* Force it to stay alive for a bit longer. */
lua_pushvalue (L, -1);
lua_insert (L, 1);
/* Draw the symbol. */
if (lua_pcall (L, 1, 0, 0))
{
g_warning ("Lua error: %s", lua_tostring (L, -1));
lua_pop (L, 1);
}
/* Copy the userdata back and invalidate it, so that malicious Lua
* scripts won't succeed at drawing onto a long invalid Cairo context.
*/
memcpy (data, luadata, sizeof *data);
memset (luadata, 0, sizeof *data);
return 0; return 0;
} }
@ -412,9 +376,7 @@ ld_lua_private_unregister (LdLua *self, LdLuaSymbol *symbol)
g_return_if_fail (LD_IS_LUA (self)); g_return_if_fail (LD_IS_LUA (self));
g_return_if_fail (LD_IS_LUA_SYMBOL (symbol)); g_return_if_fail (LD_IS_LUA_SYMBOL (symbol));
lua_pushcfunction (self->priv->L, ld_lua_private_unregister_cb); if (lua_cpcall (self->priv->L, ld_lua_private_unregister_cb, symbol))
lua_pushlightuserdata (self->priv->L, symbol);
if (lua_pcall (self->priv->L, 1, 0, 0))
{ {
g_warning ("Lua error: %s", lua_tostring (self->priv->L, -1)); g_warning ("Lua error: %s", lua_tostring (self->priv->L, -1));
lua_pop (self->priv->L, 1); lua_pop (self->priv->L, 1);
@ -463,7 +425,8 @@ ld_lua_logdiag_register (lua_State *L)
lua_insert (L, -2); lua_insert (L, -2);
lua_concat (L, 2); lua_concat (L, 2);
g_warning ("Lua symbol registration failed: %s", lua_tostring (L, -1)); g_warning ("Lua symbol registration failed: %s",
lua_tostring (L, -1));
lua_pushboolean (L, FALSE); lua_pushboolean (L, FALSE);
} }
else else
@ -490,7 +453,6 @@ static int
process_registration (lua_State *L) process_registration (lua_State *L)
{ {
LdLuaSymbol *symbol; LdLuaSymbol *symbol;
const gchar *name;
gchar *human_name; gchar *human_name;
int i, type, types[] = int i, type, types[] =
@ -507,10 +469,7 @@ process_registration (lua_State *L)
lua_typename (L, types[i]), lua_typename (L, type)); lua_typename (L, types[i]), lua_typename (L, type));
symbol = LD_LUA_SYMBOL (lua_touserdata (L, lua_upvalueindex (1))); symbol = LD_LUA_SYMBOL (lua_touserdata (L, lua_upvalueindex (1)));
name = lua_tostring (L, 1); symbol->priv->name = g_strdup (lua_tostring (L, 1));
if (g_strstr_len (name, -1, LD_LIBRARY_IDENTIFIER_SEPARATOR))
return luaL_error (L, "Invalid symbol name.");
symbol->priv->name = g_strdup (name);
human_name = get_translation (L, 2); human_name = get_translation (L, 2);
if (!human_name) if (!human_name)
@ -578,7 +537,7 @@ read_symbol_area (lua_State *L, int index, LdRectangle *area)
{ {
lua_Number x1, x2, y1, y2; lua_Number x1, x2, y1, y2;
if (lua_rawlen (L, index) != 4) if (lua_objlen (L, index) != 4)
return FALSE; return FALSE;
lua_rawgeti (L, index, 1); lua_rawgeti (L, index, 1);
@ -626,7 +585,7 @@ read_terminals (lua_State *L, int index, LdPointArray **terminals)
LdPointArray *points; LdPointArray *points;
size_t num_points; size_t num_points;
num_points = lua_rawlen (L, index); num_points = lua_objlen (L, index);
points = ld_point_array_sized_new (num_points); points = ld_point_array_sized_new (num_points);
lua_pushnil (L); lua_pushnil (L);
@ -634,7 +593,7 @@ read_terminals (lua_State *L, int index, LdPointArray **terminals)
{ {
g_assert (points->length < points->size); g_assert (points->length < points->size);
if (!lua_istable (L, -1) || lua_rawlen (L, -1) != 2) if (!lua_istable (L, -1) || lua_objlen (L, -1) != 2)
goto read_terminals_fail; goto read_terminals_fail;
lua_rawgeti (L, -1, 1); lua_rawgeti (L, -1, 1);
@ -663,6 +622,32 @@ read_terminals_fail:
/* ===== Cairo ============================================================= */ /* ===== Cairo ============================================================= */
static void
push_cairo_object (lua_State *L, LdLuaDrawData *draw_data)
{
luaL_Reg *fn;
/* Create a table. */
lua_newtable (L);
/* Add methods. */
/* XXX: The light user data pointer gets invalid after the end of
* "render" function invocation. If the script stores the "cr" object
* in some global variable and then tries to reuse it the next time,
* the application may go SIGSEGV.
*
* The solution is creating a full user data instead, referencing
* the cairo object and dereferencing it upon garbage collection
* of the user data object.
*/
for (fn = ld_lua_cairo_table; fn->name; fn++)
{
lua_pushlightuserdata (L, draw_data);
lua_pushcclosure (L, fn->func, 1);
lua_setfield (L, -2, fn->name);
}
}
static gdouble static gdouble
get_cairo_scale (cairo_t *cr) get_cairo_scale (cairo_t *cr)
{ {
@ -672,11 +657,6 @@ get_cairo_scale (cairo_t *cr)
return dx; return dx;
} }
#define LD_LUA_CAIRO_GET_DATA \
data = luaL_checkudata (L, 1, LD_LUA_META_INDEX); \
if (!data->cr) \
return luaL_error (L, "Tried to use an invalid Cairo object");
#define LD_LUA_CAIRO_BEGIN(name) \ #define LD_LUA_CAIRO_BEGIN(name) \
static int \ static int \
ld_lua_cairo_ ## name (lua_State *L) \ ld_lua_cairo_ ## name (lua_State *L) \
@ -689,7 +669,7 @@ ld_lua_cairo_ ## name (lua_State *L) \
#define LD_LUA_CAIRO_TRIVIAL(name) \ #define LD_LUA_CAIRO_TRIVIAL(name) \
LD_LUA_CAIRO_BEGIN (name) \ LD_LUA_CAIRO_BEGIN (name) \
LD_LUA_CAIRO_GET_DATA \ data = lua_touserdata (L, lua_upvalueindex (1)); \
cairo_ ## name (data->cr); \ cairo_ ## name (data->cr); \
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)
@ -705,7 +685,7 @@ LD_LUA_CAIRO_TRIVIAL (clip)
LD_LUA_CAIRO_TRIVIAL (clip_preserve) LD_LUA_CAIRO_TRIVIAL (clip_preserve)
LD_LUA_CAIRO_BEGIN (save) LD_LUA_CAIRO_BEGIN (save)
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
if (data->save_count + 1) if (data->save_count + 1)
{ {
data->save_count++; data->save_count++;
@ -714,7 +694,7 @@ LD_LUA_CAIRO_BEGIN (save)
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)
LD_LUA_CAIRO_BEGIN (restore) LD_LUA_CAIRO_BEGIN (restore)
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
if (data->save_count) if (data->save_count)
{ {
data->save_count--; data->save_count--;
@ -723,23 +703,24 @@ LD_LUA_CAIRO_BEGIN (restore)
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)
LD_LUA_CAIRO_BEGIN (get_line_width) LD_LUA_CAIRO_BEGIN (get_line_width)
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
lua_pushnumber (L, cairo_get_line_width (data->cr) lua_pushnumber (L, cairo_get_line_width (data->cr)
* get_cairo_scale (data->cr)); * get_cairo_scale (data->cr));
LD_LUA_CAIRO_END (1) LD_LUA_CAIRO_END (1)
LD_LUA_CAIRO_BEGIN (set_line_width) LD_LUA_CAIRO_BEGIN (set_line_width)
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
cairo_set_line_width (data->cr, luaL_checknumber (L, 2) cairo_set_line_width (data->cr, luaL_checknumber (L, 1)
/ get_cairo_scale (data->cr)); / get_cairo_scale (data->cr));
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)
LD_LUA_CAIRO_BEGIN (translate) LD_LUA_CAIRO_BEGIN (translate)
lua_Number x, y; lua_Number x, y;
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
x = luaL_checknumber (L, 2);
y = luaL_checknumber (L, 3); x = luaL_checknumber (L, 1);
y = luaL_checknumber (L, 2);
cairo_translate (data->cr, x, y); cairo_translate (data->cr, x, y);
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)
@ -747,9 +728,10 @@ LD_LUA_CAIRO_END (0)
LD_LUA_CAIRO_BEGIN (scale) LD_LUA_CAIRO_BEGIN (scale)
lua_Number sx, sy; lua_Number sx, sy;
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
sx = luaL_checknumber (L, 2);
sy = luaL_checknumber (L, 3); sx = luaL_checknumber (L, 1);
sy = luaL_checknumber (L, 2);
cairo_scale (data->cr, sx, sy); cairo_scale (data->cr, sx, sy);
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)
@ -757,17 +739,18 @@ LD_LUA_CAIRO_END (0)
LD_LUA_CAIRO_BEGIN (rotate) LD_LUA_CAIRO_BEGIN (rotate)
lua_Number angle; lua_Number angle;
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
angle = luaL_checknumber (L, 2); angle = luaL_checknumber (L, 1);
cairo_rotate (data->cr, angle); cairo_rotate (data->cr, angle);
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)
LD_LUA_CAIRO_BEGIN (move_to) LD_LUA_CAIRO_BEGIN (move_to)
lua_Number x, y; lua_Number x, y;
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
x = luaL_checknumber (L, 2);
y = luaL_checknumber (L, 3); x = luaL_checknumber (L, 1);
y = luaL_checknumber (L, 2);
cairo_move_to (data->cr, x, y); cairo_move_to (data->cr, x, y);
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)
@ -775,9 +758,10 @@ LD_LUA_CAIRO_END (0)
LD_LUA_CAIRO_BEGIN (line_to) LD_LUA_CAIRO_BEGIN (line_to)
lua_Number x, y; lua_Number x, y;
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
x = luaL_checknumber (L, 2);
y = luaL_checknumber (L, 3); x = luaL_checknumber (L, 1);
y = luaL_checknumber (L, 2);
cairo_line_to (data->cr, x, y); cairo_line_to (data->cr, x, y);
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)
@ -785,13 +769,14 @@ LD_LUA_CAIRO_END (0)
LD_LUA_CAIRO_BEGIN (curve_to) LD_LUA_CAIRO_BEGIN (curve_to)
lua_Number x1, y1, x2, y2, x3, y3; lua_Number x1, y1, x2, y2, x3, y3;
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
x1 = luaL_checknumber (L, 2);
y1 = luaL_checknumber (L, 3); x1 = luaL_checknumber (L, 1);
x2 = luaL_checknumber (L, 4); y1 = luaL_checknumber (L, 2);
y2 = luaL_checknumber (L, 5); x2 = luaL_checknumber (L, 3);
x3 = luaL_checknumber (L, 6); y2 = luaL_checknumber (L, 4);
y3 = luaL_checknumber (L, 7); x3 = luaL_checknumber (L, 5);
y3 = luaL_checknumber (L, 6);
cairo_curve_to (data->cr, x1, y1, x2, y2, x3, y3); cairo_curve_to (data->cr, x1, y1, x2, y2, x3, y3);
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)
@ -799,12 +784,13 @@ LD_LUA_CAIRO_END (0)
LD_LUA_CAIRO_BEGIN (arc) LD_LUA_CAIRO_BEGIN (arc)
lua_Number xc, yc, radius, angle1, angle2; lua_Number xc, yc, radius, angle1, angle2;
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
xc = luaL_checknumber (L, 2);
yc = luaL_checknumber (L, 3); xc = luaL_checknumber (L, 1);
radius = luaL_checknumber (L, 4); yc = luaL_checknumber (L, 2);
angle1 = luaL_checknumber (L, 5); radius = luaL_checknumber (L, 3);
angle2 = luaL_checknumber (L, 6); angle1 = luaL_checknumber (L, 4);
angle2 = luaL_checknumber (L, 5);
cairo_arc (data->cr, xc, yc, radius, angle1, angle2); cairo_arc (data->cr, xc, yc, radius, angle1, angle2);
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)
@ -812,38 +798,33 @@ LD_LUA_CAIRO_END (0)
LD_LUA_CAIRO_BEGIN (arc_negative) LD_LUA_CAIRO_BEGIN (arc_negative)
lua_Number xc, yc, radius, angle1, angle2; lua_Number xc, yc, radius, angle1, angle2;
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
xc = luaL_checknumber (L, 2);
yc = luaL_checknumber (L, 3); xc = luaL_checknumber (L, 1);
radius = luaL_checknumber (L, 4); yc = luaL_checknumber (L, 2);
angle1 = luaL_checknumber (L, 5); radius = luaL_checknumber (L, 3);
angle2 = luaL_checknumber (L, 6); angle1 = luaL_checknumber (L, 4);
angle2 = luaL_checknumber (L, 5);
cairo_arc_negative (data->cr, xc, yc, radius, angle1, angle2); cairo_arc_negative (data->cr, xc, yc, radius, angle1, angle2);
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)
LD_LUA_CAIRO_BEGIN (show_text) LD_LUA_CAIRO_BEGIN (show_text)
const char *text; const char *text;
GtkStyleContext *style; GtkStyle *style;
const PangoFontDescription *orig_font_desc;
PangoFontDescription *font_desc;
PangoLayout *layout; PangoLayout *layout;
int width, height; int width, height;
double x, y; double x, y;
LD_LUA_CAIRO_GET_DATA data = lua_touserdata (L, lua_upvalueindex (1));
text = luaL_checkstring (L, 2); text = luaL_checkstring (L, 1);
layout = pango_cairo_create_layout (data->cr); layout = pango_cairo_create_layout (data->cr);
pango_layout_set_text (layout, text, -1); pango_layout_set_text (layout, text, -1);
style = gtk_style_context_new (); style = gtk_style_new ();
gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, pango_font_description_set_size (style->font_desc, 1 * PANGO_SCALE);
GTK_STYLE_PROPERTY_FONT, &orig_font_desc, NULL); pango_layout_set_font_description (layout, style->font_desc);
font_desc = pango_font_description_copy (orig_font_desc);
pango_font_description_set_size (font_desc, 1 * PANGO_SCALE);
pango_layout_set_font_description (layout, font_desc);
pango_font_description_free (font_desc);
g_object_unref (style); g_object_unref (style);
pango_layout_get_size (layout, &width, &height); pango_layout_get_size (layout, &width, &height);
@ -858,3 +839,4 @@ LD_LUA_CAIRO_BEGIN (show_text)
g_object_unref (layout); g_object_unref (layout);
LD_LUA_CAIRO_END (0) LD_LUA_CAIRO_END (0)

View File

@ -2,7 +2,7 @@
* ld-lua.h * ld-lua.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -15,14 +15,16 @@ G_BEGIN_DECLS
#define LD_TYPE_LUA (ld_lua_get_type ()) #define LD_TYPE_LUA (ld_lua_get_type ())
#define LD_LUA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_LUA, LdLua)) #define LD_LUA(obj) (G_TYPE_CHECK_INSTANCE_CAST \
#define LD_LUA_CLASS(klass) \ ((obj), LD_TYPE_LUA, LdLua))
(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_LUA, LdLuaClass)) #define LD_LUA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
#define LD_IS_LUA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_LUA)) ((klass), LD_TYPE_LUA, LdLuaClass))
#define LD_IS_LUA_CLASS(klass) \ #define LD_IS_LUA(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_LUA)) ((obj), LD_TYPE_LUA))
#define LD_LUA_GET_CLASS(obj) \ #define LD_IS_LUA_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_LUA, LdLuaClass)) ((klass), LD_TYPE_LUA))
#define LD_LUA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
((obj), LD_LUA, LdLuaClass))
typedef struct _LdLua LdLua; typedef struct _LdLua LdLua;
typedef struct _LdLuaPrivate LdLuaPrivate; typedef struct _LdLuaPrivate LdLuaPrivate;
@ -65,3 +67,4 @@ gboolean ld_lua_load_file (LdLua *self, const gchar *filename,
G_END_DECLS G_END_DECLS
#endif /* ! __LD_LUA_H__ */ #endif /* ! __LD_LUA_H__ */

View File

@ -1,2 +1,3 @@
VOID:OBJECT,OBJECT
VOID:OBJECT,STRING VOID:OBJECT,STRING
VOID:DOUBLE,DOUBLE VOID:DOUBLE,DOUBLE

View File

@ -0,0 +1,339 @@
/*
* ld-symbol-category.c
*
* This file is a part of logdiag.
* Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
*
* See the file LICENSE for licensing information.
*
*/
#include "liblogdiag.h"
#include "config.h"
/**
* SECTION:ld-symbol-category
* @short_description: A category of symbols
* @see_also: #LdSymbol, #LdLibrary
*
* #LdSymbolCategory represents a category of #LdSymbol objects.
*/
/*
* LdSymbolCategoryPrivate:
* @name: the name of this category.
* @image_path: path to the image for this category.
* @children: children of this category.
*/
struct _LdSymbolCategoryPrivate
{
gchar *name;
gchar *human_name;
gchar *image_path;
GSList *children;
};
enum
{
PROP_0,
PROP_NAME,
PROP_HUMAN_NAME,
PROP_IMAGE_PATH
};
static void ld_symbol_category_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec);
static void ld_symbol_category_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec);
static void ld_symbol_category_finalize (GObject *gobject);
G_DEFINE_TYPE (LdSymbolCategory, ld_symbol_category, G_TYPE_OBJECT);
static void
ld_symbol_category_class_init (LdSymbolCategoryClass *klass)
{
GObjectClass *object_class;
GParamSpec *pspec;
object_class = G_OBJECT_CLASS (klass);
object_class->get_property = ld_symbol_category_get_property;
object_class->set_property = ld_symbol_category_set_property;
object_class->finalize = ld_symbol_category_finalize;
/**
* LdSymbolCategory:name:
*
* The name of this symbol category.
*/
pspec = g_param_spec_string ("name", "Name",
"The name of this symbol category.",
"", G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_NAME, pspec);
/**
* LdSymbolCategory:human-name:
*
* The localized human name of this symbol category.
*/
pspec = g_param_spec_string ("human-name", "Human name",
"The localized human name of this symbol category.",
"", G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_HUMAN_NAME, pspec);
/**
* LdSymbolCategory:image-path:
*
* Path to an image file representing this category.
*/
pspec = g_param_spec_string ("image-path", "Image path",
"Path to an image file representing this category.",
"", G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_IMAGE_PATH, pspec);
g_type_class_add_private (klass, sizeof (LdSymbolCategoryPrivate));
}
static void
ld_symbol_category_init (LdSymbolCategory *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE
(self, LD_TYPE_SYMBOL_CATEGORY, LdSymbolCategoryPrivate);
}
static void
ld_symbol_category_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec)
{
LdSymbolCategory *self;
self = LD_SYMBOL_CATEGORY (object);
switch (property_id)
{
case PROP_NAME:
g_value_set_string (value, ld_symbol_category_get_name (self));
break;
case PROP_HUMAN_NAME:
g_value_set_string (value, ld_symbol_category_get_human_name (self));
break;
case PROP_IMAGE_PATH:
g_value_set_string (value, ld_symbol_category_get_image_path (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
ld_symbol_category_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec)
{
LdSymbolCategory *self;
self = LD_SYMBOL_CATEGORY (object);
switch (property_id)
{
case PROP_NAME:
ld_symbol_category_set_name (self, g_value_get_string (value));
break;
case PROP_HUMAN_NAME:
ld_symbol_category_set_human_name (self, g_value_get_string (value));
break;
case PROP_IMAGE_PATH:
ld_symbol_category_set_image_path (self, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
ld_symbol_category_finalize (GObject *gobject)
{
LdSymbolCategory *self;
self = LD_SYMBOL_CATEGORY (gobject);
if (self->priv->name)
g_free (self->priv->name);
if (self->priv->human_name)
g_free (self->priv->human_name);
if (self->priv->image_path)
g_free (self->priv->image_path);
g_slist_foreach (self->priv->children, (GFunc) g_object_unref, NULL);
g_slist_free (self->priv->children);
/* Chain up to the parent class. */
G_OBJECT_CLASS (ld_symbol_category_parent_class)->finalize (gobject);
}
/**
* ld_symbol_category_new:
* @name: the name of the new category.
* @human_name: the localized human name of the new category.
*
* Create an instance.
*/
LdSymbolCategory *
ld_symbol_category_new (const gchar *name, const gchar *human_name)
{
LdSymbolCategory *cat;
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (human_name != NULL, NULL);
cat = g_object_new (LD_TYPE_SYMBOL_CATEGORY, NULL);
cat->priv->name = g_strdup (name);
cat->priv->human_name = g_strdup (human_name);
return cat;
}
/**
* ld_symbol_category_set_name:
* @self: an #LdSymbolCategory object.
* @name: the new name for this category.
*/
void
ld_symbol_category_set_name (LdSymbolCategory *self, const gchar *name)
{
g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
g_return_if_fail (name != NULL);
if (self->priv->name)
g_free (self->priv->name);
self->priv->name = g_strdup (name);
g_object_notify (G_OBJECT (self), "name");
}
/**
* ld_symbol_category_get_name:
* @self: an #LdSymbolCategory object.
*
* Return the name of this category.
*/
const gchar *
ld_symbol_category_get_name (LdSymbolCategory *self)
{
g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), NULL);
return self->priv->name;
}
/**
* ld_symbol_category_set_human_name:
* @self: an #LdSymbolCategory object.
* @human_name: the new localized human name for this category.
*/
void
ld_symbol_category_set_human_name (LdSymbolCategory *self,
const gchar *human_name)
{
g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
g_return_if_fail (human_name != NULL);
if (self->priv->human_name)
g_free (self->priv->human_name);
self->priv->human_name = g_strdup (human_name);
g_object_notify (G_OBJECT (self), "human-name");
}
/**
* ld_symbol_category_get_human_name:
* @self: an #LdSymbolCategory object.
*
* Return the localized human name of this category.
*/
const gchar *
ld_symbol_category_get_human_name (LdSymbolCategory *self)
{
g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), NULL);
return self->priv->human_name;
}
/**
* ld_symbol_category_set_image_path:
* @self: an #LdSymbolCategory object.
* @image_path: (allow-none): The new path to the image for this category.
*/
void
ld_symbol_category_set_image_path (LdSymbolCategory *self,
const gchar *image_path)
{
g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
if (self->priv->image_path)
g_free (self->priv->image_path);
self->priv->image_path = g_strdup (image_path);
g_object_notify (G_OBJECT (self), "image-path");
}
/**
* ld_symbol_category_get_image_path:
* @self: an #LdSymbolCategory object.
*
* Return value: (allow-none): filesystem path to the image for this category.
*/
const gchar *
ld_symbol_category_get_image_path (LdSymbolCategory *self)
{
g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), NULL);
return self->priv->image_path;
}
/**
* ld_symbol_category_insert_child:
* @self: an #LdSymbolCategory object.
* @child: the child to be inserted.
* @pos: the position at which the child will be inserted.
* Negative values will append to the end of list.
*
* Insert a child into the category.
*/
void
ld_symbol_category_insert_child (LdSymbolCategory *self,
GObject *child, gint pos)
{
g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
g_return_if_fail (G_IS_OBJECT (child));
g_object_ref (child);
self->priv->children = g_slist_insert (self->priv->children, child, pos);
}
/**
* ld_symbol_category_remove_child:
* @self: an #LdSymbolCategory object.
* @child: the child to be removed.
*
* Removes a child from the category.
*/
void
ld_symbol_category_remove_child (LdSymbolCategory *self,
GObject *child)
{
g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
g_return_if_fail (G_IS_OBJECT (child));
g_object_unref (child);
self->priv->children = g_slist_remove (self->priv->children, child);
}
/**
* ld_symbol_category_get_children:
* @self: an #LdSymbolCategory object.
*
* Return value: (element-type GObject): a list of children. Do not modify.
*/
const GSList *
ld_symbol_category_get_children (LdSymbolCategory *self)
{
g_return_val_if_fail (LD_IS_SYMBOL_CATEGORY (self), NULL);
return self->priv->children;
}

View File

@ -0,0 +1,79 @@
/*
* ld-symbol-category.h
*
* This file is a part of logdiag.
* Copyright Přemysl Janouch 2010. All rights reserved.
*
* See the file LICENSE for licensing information.
*
*/
#ifndef __LD_SYMBOL_CATEGORY_H__
#define __LD_SYMBOL_CATEGORY_H__
G_BEGIN_DECLS
#define LD_TYPE_SYMBOL_CATEGORY (ld_symbol_category_get_type ())
#define LD_SYMBOL_CATEGORY(obj) (G_TYPE_CHECK_INSTANCE_CAST \
((obj), LD_TYPE_SYMBOL_CATEGORY, LdSymbolCategory))
#define LD_SYMBOL_CATEGORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
((klass), LD_TYPE_SYMBOL_CATEGORY, LdSymbolCategoryClass))
#define LD_IS_SYMBOL_CATEGORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
((obj), LD_TYPE_SYMBOL_CATEGORY))
#define LD_IS_SYMBOL_CATEGORY_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
((klass), LD_TYPE_SYMBOL_CATEGORY))
#define LD_SYMBOL_CATEGORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
((obj), LD_SYMBOL_CATEGORY, LdSymbolCategoryClass))
typedef struct _LdSymbolCategory LdSymbolCategory;
typedef struct _LdSymbolCategoryPrivate LdSymbolCategoryPrivate;
typedef struct _LdSymbolCategoryClass LdSymbolCategoryClass;
/**
* LdSymbolCategory:
*/
struct _LdSymbolCategory
{
/*< private >*/
GObject parent_instance;
LdSymbolCategoryPrivate *priv;
};
/* TODO: If required sometime, categories (and maybe symbols) should implement
* a "changed" signal. This can be somewhat tricky. The library might be
* a good candidate for what they call a proxy. See GtkUIManager.
*/
struct _LdSymbolCategoryClass
{
/*< private >*/
GObjectClass parent_class;
};
GType ld_symbol_category_get_type (void) G_GNUC_CONST;
LdSymbolCategory *ld_symbol_category_new (const gchar *name,
const gchar *human_name);
void ld_symbol_category_set_name (LdSymbolCategory *self, const gchar *name);
const gchar *ld_symbol_category_get_name (LdSymbolCategory *self);
void ld_symbol_category_set_human_name (LdSymbolCategory *self,
const gchar *human_name);
const gchar *ld_symbol_category_get_human_name (LdSymbolCategory *self);
void ld_symbol_category_set_image_path (LdSymbolCategory *self,
const gchar *image_path);
const gchar *ld_symbol_category_get_image_path (LdSymbolCategory *self);
void ld_symbol_category_insert_child (LdSymbolCategory *self,
GObject *child, gint pos);
void ld_symbol_category_remove_child (LdSymbolCategory *self,
GObject *child);
const GSList *ld_symbol_category_get_children (LdSymbolCategory *self);
G_END_DECLS
#endif /* ! __LD_SYMBOL_CATEGORY_H__ */

View File

@ -2,7 +2,7 @@
* ld-symbol.c * ld-symbol.c
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -38,7 +38,7 @@ static void ld_symbol_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec); const GValue *value, GParamSpec *pspec);
G_DEFINE_ABSTRACT_TYPE (LdSymbol, ld_symbol, G_TYPE_OBJECT) G_DEFINE_ABSTRACT_TYPE (LdSymbol, ld_symbol, G_TYPE_OBJECT);
static void static void
ld_symbol_class_init (LdSymbolClass *klass) ld_symbol_class_init (LdSymbolClass *klass)

View File

@ -2,7 +2,7 @@
* ld-symbol.h * ld-symbol.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -15,15 +15,16 @@ G_BEGIN_DECLS
#define LD_TYPE_SYMBOL (ld_symbol_get_type ()) #define LD_TYPE_SYMBOL (ld_symbol_get_type ())
#define LD_SYMBOL(obj) \ #define LD_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_SYMBOL, LdSymbol)) ((obj), LD_TYPE_SYMBOL, LdSymbol))
#define LD_SYMBOL_CLASS(klass) \ #define LD_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_SYMBOL, LdSymbolClass)) ((klass), LD_TYPE_SYMBOL, LdSymbolClass))
#define LD_IS_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_SYMBOL)) #define LD_IS_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
#define LD_IS_SYMBOL_CLASS(klass) \ ((obj), LD_TYPE_SYMBOL))
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_SYMBOL)) #define LD_IS_SYMBOL_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
#define LD_SYMBOL_GET_CLASS(obj) \ ((klass), LD_TYPE_SYMBOL))
(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_SYMBOL, LdSymbolClass)) #define LD_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
((obj), LD_SYMBOL, LdSymbolClass))
typedef struct _LdSymbol LdSymbol; typedef struct _LdSymbol LdSymbol;
typedef struct _LdSymbolPrivate LdSymbolPrivate; typedef struct _LdSymbolPrivate LdSymbolPrivate;
@ -71,3 +72,4 @@ void ld_symbol_draw (LdSymbol *self, cairo_t *cr);
G_END_DECLS G_END_DECLS
#endif /* ! __LD_SYMBOL_H__ */ #endif /* ! __LD_SYMBOL_H__ */

View File

@ -2,7 +2,7 @@
* ld-types.c * ld-types.c
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -256,8 +256,7 @@ ld_point_array_remove (LdPointArray *self, gint pos, guint length)
* *
* Change size of the array. * Change size of the array.
*/ */
void void ld_point_array_set_size (LdPointArray *self, guint size)
ld_point_array_set_size (LdPointArray *self, guint size)
{ {
g_return_if_fail (self != NULL); g_return_if_fail (self != NULL);

View File

@ -2,7 +2,7 @@
* ld-types.h * ld-types.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2010, 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -99,3 +99,4 @@ void ld_rectangle_extend (LdRectangle *self, gdouble border);
G_END_DECLS G_END_DECLS
#endif /* ! __LD_TYPES_H__ */ #endif /* ! __LD_TYPES_H__ */

View File

@ -2,7 +2,7 @@
* ld-undo-action.c * ld-undo-action.c
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -40,7 +40,7 @@ struct _LdUndoActionPrivate
static void ld_undo_action_finalize (GObject *gobject); static void ld_undo_action_finalize (GObject *gobject);
G_DEFINE_TYPE (LdUndoAction, ld_undo_action, G_TYPE_OBJECT) G_DEFINE_TYPE (LdUndoAction, ld_undo_action, G_TYPE_OBJECT);
static void static void
ld_undo_action_class_init (LdUndoActionClass *klass) ld_undo_action_class_init (LdUndoActionClass *klass)
@ -84,8 +84,9 @@ ld_undo_action_finalize (GObject *gobject)
* Return value: a new #LdUndoAction object. * Return value: a new #LdUndoAction object.
*/ */
LdUndoAction * LdUndoAction *
ld_undo_action_new (LdUndoActionFunc undo_func, LdUndoActionFunc redo_func, ld_undo_action_new (LdUndoActionFunc undo_func,
LdUndoActionFunc destroy_func, gpointer user_data) LdUndoActionFunc redo_func, LdUndoActionFunc destroy_func,
gpointer user_data)
{ {
LdUndoAction *self; LdUndoAction *self;

View File

@ -2,7 +2,7 @@
* ld-undo-action.h * ld-undo-action.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2011 Přemysl Eric Janouch * Copyright Přemysl Janouch 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -15,16 +15,16 @@ G_BEGIN_DECLS
#define LD_TYPE_UNDO_ACTION (ld_undo_action_get_type ()) #define LD_TYPE_UNDO_ACTION (ld_undo_action_get_type ())
#define LD_UNDO_ACTION(obj) \ #define LD_UNDO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_UNDO_ACTION, LdUndoAction)) ((obj), LD_TYPE_UNDO_ACTION, LdUndoAction))
#define LD_UNDO_ACTION_CLASS(klass) \ #define LD_UNDO_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_UNDO_ACTION, LdUndoActionClass)) ((klass), LD_TYPE_UNDO_ACTION, LdUndoActionClass))
#define LD_IS_UNDO_ACTION(obj) \ #define LD_IS_UNDO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_UNDO_ACTION)) ((obj), LD_TYPE_UNDO_ACTION))
#define LD_IS_UNDO_ACTION_CLASS(klass) \ #define LD_IS_UNDO_ACTION_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_UNDO_ACTION)) ((klass), LD_TYPE_UNDO_ACTION))
#define LD_UNDO_ACTION_GET_CLASS(obj) \ #define LD_UNDO_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_UNDO_ACTION, LdUndoActionClass)) ((obj), LD_UNDO_ACTION, LdUndoActionClass))
typedef struct _LdUndoAction LdUndoAction; typedef struct _LdUndoAction LdUndoAction;
typedef struct _LdUndoActionPrivate LdUndoActionPrivate; typedef struct _LdUndoActionPrivate LdUndoActionPrivate;
@ -73,3 +73,4 @@ void ld_undo_action_redo (LdUndoAction *self);
G_END_DECLS G_END_DECLS
#endif /* ! __LD_UNDO_ACTION_H__ */ #endif /* ! __LD_UNDO_ACTION_H__ */

View File

@ -2,7 +2,7 @@
* liblogdiag.h * liblogdiag.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright 2011, 2012 Přemysl Eric Janouch * Copyright Přemysl Janouch 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -11,15 +11,6 @@
#ifndef __LIBLOGDIAG_H__ #ifndef __LIBLOGDIAG_H__
#define __LIBLOGDIAG_H__ #define __LIBLOGDIAG_H__
/* Whatever, I don't care, someone should at least appreciate my effort of
* porting it to GTK+ 3 in the first place. You make me work for free!
*/
#ifdef GDK_VERSION_3_8
#define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_8
#else // ! GDK_VERSION_3_8
#define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_4
#endif // ! GDK_VERSION_3_8
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <json-glib/json-glib.h> #include <json-glib/json-glib.h>
@ -27,7 +18,7 @@
#include "ld-types.h" #include "ld-types.h"
#include "ld-symbol.h" #include "ld-symbol.h"
#include "ld-category.h" #include "ld-symbol-category.h"
#include "ld-library.h" #include "ld-library.h"
#include "ld-undo-action.h" #include "ld-undo-action.h"
@ -37,9 +28,7 @@
#include "ld-diagram.h" #include "ld-diagram.h"
#include "ld-diagram-view.h" #include "ld-diagram-view.h"
#include "ld-category-view.h" #include "ld-library-toolbar.h"
#include "ld-category-symbol-view.h"
#include "ld-category-tree-view.h"
#include "ld-lua.h" #include "ld-lua.h"
#include "ld-lua-symbol.h" #include "ld-lua-symbol.h"

200
po/cs.po
View File

@ -1,274 +1,198 @@
# Czech translation for logdiag. # Czech translation for logdiag.
# Copyright (C) 2011 Přemysl Eric Janouch # Copyright (C) 2011 Přemysl Janouch
# This file is distributed under the same license as the logdiag package. # This file is distributed under the same license as the logdiag package.
# Přemysl Eric Janouch <p@janouch.name>, 2011. # Přemysl Janouch <p.janouch@gmail.com>, 2011.
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: logdiag\n" "Project-Id-Version: logdiag\n"
"Report-Msgid-Bugs-To: https://git.janouch.name/p/logdiag/issues\n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-10-28 20:07+0200\n" "POT-Creation-Date: 2011-02-13 20:25+0100\n"
"PO-Revision-Date: 2021-10-28 20:10+0200\n" "PO-Revision-Date: 2011-02-13 20:36+0100\n"
"Last-Translator: Přemysl Eric Janouch <p@janouch.name>\n" "Last-Translator: Přemysl Janouch <p.janouch@gmail.com>\n"
"Language-Team: Czech <cs@li.org>\n" "Language-Team: Czech <LL@li.org>\n"
"Language: cs\n" "Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0\n"
#: ../src/ld-window-main.c:968 #: ../src/ld-window-main.c:736
#, c-format
msgid "%d%%"
msgstr "%d %%"
#: ../src/logdiag.c:147
msgid "- Schematic editor"
msgstr "- Editor schémat"
#: ../src/ld-window-main.c:892
msgid "Close _without Saving" msgid "Close _without Saving"
msgstr "Zavřít _bez uložení" msgstr "Zavřít _bez uložení"
#: ../src/ld-window-main.c:141 #: ../src/ld-window-main.c:116
msgid "Create a new diagram" msgid "Create a new diagram"
msgstr "Vytvoří nový diagram" msgstr "Vytvoří nový diagram"
#: ../src/ld-window-main.c:174 #: ../src/ld-window-main.c:149
msgid "Delete the contents of the selection" msgid "Delete the contents of the selection"
msgstr "Odstraní obsah výběru" msgstr "Odstraní obsah výběru"
#: ../src/ld-window-main.c:370 #: ../src/ld-window-main.c:604
msgid "Drag symbols from the library pane to add them to the diagram."
msgstr "Pro přidání symbolů do diagramu je přetáhněte z panelu knihovny."
#: ../liblogdiag/ld-category-tree-view.c:138
msgid "Empty"
msgstr "Prázdné"
#: ../src/ld-window-main.c:1042
msgid "Error"
msgstr "Chyba"
#: ../src/ld-window-main.c:738
#, c-format
msgid "Failed to open file `%s': Invalid contents."
msgstr "Nelze otevřít soubor \"%s\": Neplatný obsah."
#: ../src/ld-window-main.c:729
msgid "Failed to open the file" msgid "Failed to open the file"
msgstr "Nelze otevřít soubor" msgstr "Nelze otevřít soubor"
#: ../src/ld-window-main.c:1149 #: ../src/ld-window-main.c:569
msgid "Failed to open the user guide"
msgstr "Nelze otevřít průvodce uživatele"
#: ../src/ld-window-main.c:693
msgid "Failed to save the diagram" msgid "Failed to save the diagram"
msgstr "Nelze uložit diagram" msgstr "Nelze uložit diagram"
#: ../src/ld-window-main.c:890 #: ../src/ld-window-main.c:734
msgid "If you don't save, changes will be permanently lost." msgid "If you don't save, changes will be permanently lost."
msgstr "Pokud je neuložíte, budou změny navždy ztraceny." msgstr "Pokud je neuložíte, budou změny navždy ztraceny."
#: ../src/ld-window-main.c:769 #: ../src/ld-window-main.c:629
msgid "Logdiag Diagrams (*.ldd)" msgid "Logdiag Diagrams (*.ldd)"
msgstr "Diagramy logdiag (*.ldd)" msgstr "Diagramy logdiag (*.ldd)"
#: ../src/ld-window-main.c:144 #: ../src/ld-window-main.c:119
msgid "Open a diagram" msgid "Open a diagram"
msgstr "Otevře diagram" msgstr "Otevře diagram"
#: ../src/ld-window-main.c:193 #: ../src/ld-window-main.c:650
msgid "Open the manual"
msgstr "Otevře manuál"
#: ../src/ld-window-main.c:790
msgid "Open..." msgid "Open..."
msgstr "Otevřít..." msgstr "Otevřít..."
#: ../src/ld-window-main.c:154 #: ../src/ld-window-main.c:133
msgid "Print the diagram"
msgstr "Vytiskne diagram"
#: ../src/ld-window-main.c:158
msgid "Quit the application" msgid "Quit the application"
msgstr "Ukončí aplikaci" msgstr "Ukončí aplikaci"
#: ../src/ld-window-main.c:166 #: ../src/ld-window-main.c:141
msgid "Redo the last undone action" msgid "Redo the last undone action"
msgstr "Provede posledně vrácenou akci" msgstr "Provede posledně vrácenou akci"
#: ../src/ld-window-main.c:188 #: ../src/ld-window-main.c:163
msgid "Reset zoom level back to the default" msgid "Reset zoom level back to the default"
msgstr "Vrátí přiblížení na výchozí hodnotu" msgstr "Vrátí přiblížení na výchozí hodnotu"
#: ../src/ld-window-main.c:823 #: ../src/ld-window-main.c:681
msgid "Save As..." msgid "Save As..."
msgstr "Uložit jako..." msgstr "Uložit jako..."
#: ../src/ld-window-main.c:149 #: ../src/ld-window-main.c:124
msgid "Save _As..." msgid "Save _As..."
msgstr "Uložit _jako..." msgstr "Uložit _jako..."
#: ../src/ld-window-main.c:654 #: ../src/ld-window-main.c:525
#, c-format #, c-format
msgid "Save the changes to diagram \"%s\" before closing it and creating a new one?" msgid ""
"Save the changes to diagram \"%s\" before closing it and creating a new one?"
msgstr "Uložit změny v diagramu \"%s\" před jeho zavřením a vytvořením nového?" msgstr "Uložit změny v diagramu \"%s\" před jeho zavřením a vytvořením nového?"
#: ../src/ld-window-main.c:786 #: ../src/ld-window-main.c:646
#, c-format #, c-format
msgid "Save the changes to diagram \"%s\" before closing it and opening another one?" msgid ""
"Save the changes to diagram \"%s\" before closing it and opening another one?"
msgstr "Uložit změny v diagramu \"%s\" před jeho zavřením a otevřením jiného?" msgstr "Uložit změny v diagramu \"%s\" před jeho zavřením a otevřením jiného?"
#: ../src/ld-window-main.c:930 #: ../src/ld-window-main.c:774
#, c-format #, c-format
msgid "Save the changes to diagram \"%s\" before closing?" msgid "Save the changes to diagram \"%s\" before closing?"
msgstr "Uložit změny v diagramu \"%s\" před jeho zavřením?" msgstr "Uložit změny v diagramu \"%s\" před jeho zavřením?"
#: ../src/ld-window-main.c:147 #: ../src/ld-window-main.c:122
msgid "Save the current diagram" msgid "Save the current diagram"
msgstr "Uloží stávající diagram" msgstr "Uloží stávající diagram"
#: ../src/ld-window-main.c:150 #: ../src/ld-window-main.c:125
msgid "Save the current diagram with another name" msgid "Save the current diagram with another name"
msgstr "Uloží stávající diagram pod jiným jménem" msgstr "Uloží stávající diagram pod jiným jménem"
#: ../src/ld-window-main.c:176 #: ../src/ld-window-main.c:151
msgid "Select _All" msgid "Select _All"
msgstr "Vybrat _vše" msgstr "Vybrat _vše"
#: ../src/ld-window-main.c:177 #: ../src/ld-window-main.c:152
msgid "Select all objects in the diagram" msgid "Select all objects in the diagram"
msgstr "Vybere všechny objekty v diagramu" msgstr "Vybere všechny objekty v diagramu"
#: ../src/ld-window-main.c:208 #: ../src/ld-window-main.c:168
msgid "Show _Grid"
msgstr "Zobrazit _mřížku"
#: ../src/ld-window-main.c:196
msgid "Show a dialog about this application" msgid "Show a dialog about this application"
msgstr "Zobrazí dialog o této aplikaci" msgstr "Zobrazí dialog o této aplikaci"
#: ../src/ld-window-main.c:209 #: ../src/ld-window-main.c:607
msgid "Toggle displaying of the grid" msgid "The file is probably corrupted."
msgstr "Přepne zobrazování mřížky" msgstr "Soubor je pravděpodobně poškozen."
#: ../src/ld-window-main.c:206 #: ../src/ld-window-main.c:572
msgid "Toggle displaying of the library pane"
msgstr "Přepne zobrazování panelu knihovny"
#: ../src/ld-window-main.c:203
msgid "Toggle displaying of the main toolbar"
msgstr "Přepne zobrazování hlavního panelu nástrojů"
#: ../src/ld-window-main.c:696
msgid "Try again or save it under another name." msgid "Try again or save it under another name."
msgstr "Zkuste to znova nebo jej uložte pod jiným názvem." msgstr "Zkuste to znova nebo jej uložte pod jiným názvem."
#: ../src/ld-window-main.c:163 #: ../src/ld-window-main.c:138
msgid "Undo the last action" msgid "Undo the last action"
msgstr "Vrátí poslední akci" msgstr "Vrátí poslední akci"
#: ../src/ld-window-main.c:622 #: ../src/ld-window-main.c:493
msgid "Unsaved Diagram" msgid "Unsaved Diagram"
msgstr "Neuložený diagram" msgstr "Neuložený diagram"
#: ../src/ld-window-main.c:837 #: ../src/ld-window-main.c:159
msgid "Untitled diagram"
msgstr "Nepojmenovaný diagram"
#: ../src/ld-window-main.c:184
msgid "Zoom _Out" msgid "Zoom _Out"
msgstr "_Oddálit" msgstr "_Oddálit"
#: ../src/ld-window-main.c:182 #: ../src/ld-window-main.c:157
msgid "Zoom into the diagram" msgid "Zoom into the diagram"
msgstr "Přiblíží diagram" msgstr "Přiblíží diagram"
#: ../src/ld-window-main.c:185 #: ../src/ld-window-main.c:160
msgid "Zoom out of the diagram" msgid "Zoom out of the diagram"
msgstr "Oddálí diagram" msgstr "Oddálí diagram"
#: ../src/logdiag.c:106 #: ../src/logdiag.c:33
msgid "[FILE...]" msgid "[FILE] - Schematic editor"
msgstr "[SOUBOR...]" msgstr "[SOUBOR] - Editor schémat"
#: ../src/ld-window-main.c:195 #: ../src/ld-window-main.c:167
msgid "_About" msgid "_About"
msgstr "_O programu" msgstr "_O programu"
#: ../src/ld-window-main.c:173 #: ../src/ld-window-main.c:148
msgid "_Delete" msgid "_Delete"
msgstr "_Smazat" msgstr "_Smazat"
#: ../src/ld-window-main.c:161 #: ../src/ld-window-main.c:136
msgid "_Edit" msgid "_Edit"
msgstr "_Úpravy" msgstr "_Úpravy"
#: ../src/ld-window-main.c:139 #: ../src/ld-window-main.c:114
msgid "_File" msgid "_File"
msgstr "_Soubor" msgstr "_Soubor"
#: ../src/ld-window-main.c:191 #: ../src/ld-window-main.c:166
msgid "_Help" msgid "_Help"
msgstr "_Nápověda" msgstr "_Nápověda"
#: ../src/ld-window-main.c:205 #: ../src/ld-window-main.c:115
msgid "_Library Pane"
msgstr "Panel _knihovny"
#: ../src/ld-window-main.c:202
msgid "_Main Toolbar"
msgstr "_Hlavní panel nástrojů"
#: ../src/ld-window-main.c:140
msgid "_New" msgid "_New"
msgstr "_Nový" msgstr "_Nový"
#: ../src/ld-window-main.c:187 #: ../src/ld-window-main.c:162
msgid "_Normal Size" msgid "_Normal Size"
msgstr "_Normální velikost" msgstr "_Normální velikost"
#: ../src/ld-window-main.c:143 #: ../src/ld-window-main.c:118
msgid "_Open..." msgid "_Open..."
msgstr "_Otevřít..." msgstr "_Otevřít..."
#: ../src/ld-window-main.c:153 #: ../src/ld-window-main.c:132
msgid "_Print..."
msgstr "_Tisk..."
#: ../src/ld-window-main.c:157
msgid "_Quit" msgid "_Quit"
msgstr "U_končit" msgstr "_Ukončit"
#: ../src/ld-window-main.c:165 #: ../src/ld-window-main.c:140
msgid "_Redo" msgid "_Redo"
msgstr "Z_novu" msgstr "_Znovu"
#: ../src/ld-window-main.c:146 #: ../src/ld-window-main.c:121
msgid "_Save" msgid "_Save"
msgstr "_Uložit" msgstr "_Uložit"
#: ../src/ld-window-main.c:162 #: ../src/ld-window-main.c:137
msgid "_Undo" msgid "_Undo"
msgstr "_Zpět" msgstr "_Zpět"
#: ../src/ld-window-main.c:192 #: ../src/ld-window-main.c:155
msgid "_User Guide"
msgstr "_Průvodce uživatele"
#: ../src/ld-window-main.c:180
msgid "_View" msgid "_View"
msgstr "_Zobrazení" msgstr "_Zobrazení"
#: ../src/ld-window-main.c:181 #: ../src/ld-window-main.c:156
msgid "_Zoom In" msgid "_Zoom In"
msgstr "_Přiblížit" msgstr "_Přiblížit"
#: ../src/ld-window-main.c:1163
msgid "translator-credits"
msgstr "Přemysl Eric Janouch <p@janouch.name>"
#~ msgid "The file is probably corrupted."
#~ msgstr "Soubor je pravděpodobně poškozen."

280
po/de.po
View File

@ -1,280 +0,0 @@
# German translation for logdiag.
# Copyright (C) 2011 Přemysl Eric Janouch
# This file is distributed under the same license as the logdiag package.
# Andy J., 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: logdiag\n"
"Report-Msgid-Bugs-To: https://git.janouch.name/p/logdiag/issues\n"
"POT-Creation-Date: 2021-10-28 20:07+0200\n"
"PO-Revision-Date: 2021-10-28 21:29+0200\n"
"Last-Translator: Přemysl Eric Janouch <p@janouch.name>\n"
"Language-Team: German <de@li.org>\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0\n"
#: ../src/ld-window-main.c:968
#, c-format
msgid "%d%%"
msgstr "%d %%"
#: ../src/logdiag.c:147
msgid "- Schematic editor"
msgstr "- Schema Editor"
#: ../src/ld-window-main.c:892
msgid "Close _without Saving"
msgstr "Schließen _ohne Speichern"
#: ../src/ld-window-main.c:141
msgid "Create a new diagram"
msgstr "Neues Diagramm erstellen"
#: ../src/ld-window-main.c:174
msgid "Delete the contents of the selection"
msgstr "Inhalt der markierten Einträge löschen"
#: ../src/ld-window-main.c:370
msgid "Drag symbols from the library pane to add them to the diagram."
msgstr ""
"Ziehen Sie Symbole aus dem Bibliotheksfenster, um sie dem Diagramm "
"hinzuzufügen."
#: ../liblogdiag/ld-category-tree-view.c:138
msgid "Empty"
msgstr "Leere"
#: ../src/ld-window-main.c:1042
msgid "Error"
msgstr "Fehler"
#: ../src/ld-window-main.c:738
#, c-format
msgid "Failed to open file `%s': Invalid contents."
msgstr "Fehler beim Öffnen der Datei \"%s\": Ungültiger Inhalt."
#: ../src/ld-window-main.c:729
msgid "Failed to open the file"
msgstr "Fehler beim Öffnen der Datei"
#: ../src/ld-window-main.c:1149
msgid "Failed to open the user guide"
msgstr "Fehler beim Öffnen des Benutzerhandbuchs"
#: ../src/ld-window-main.c:693
msgid "Failed to save the diagram"
msgstr "Fehler beim Speichern des Diagramms"
#: ../src/ld-window-main.c:890
msgid "If you don't save, changes will be permanently lost."
msgstr "Wenn Sie nicht speichern, gehen alle Änderungen verloren."
#: ../src/ld-window-main.c:769
msgid "Logdiag Diagrams (*.ldd)"
msgstr "Diagramme logdiag (.ldd)"
#: ../src/ld-window-main.c:144
msgid "Open a diagram"
msgstr "Diagramm öffnen"
#: ../src/ld-window-main.c:193
msgid "Open the manual"
msgstr "Die Betriebsanleitung öffnen"
#: ../src/ld-window-main.c:790
msgid "Open..."
msgstr "Öffnen..."
#: ../src/ld-window-main.c:154
msgid "Print the diagram"
msgstr "Das Diagramm drucken"
#: ../src/ld-window-main.c:158
msgid "Quit the application"
msgstr "Anwendung beenden"
#: ../src/ld-window-main.c:166
msgid "Redo the last undone action"
msgstr "Letzte nicht abgeschlossene Aktion wiederholen"
#: ../src/ld-window-main.c:188
msgid "Reset zoom level back to the default"
msgstr "Zoom Bereich zurücksetzen"
#: ../src/ld-window-main.c:823
msgid "Save As..."
msgstr "Speichern unter..."
#: ../src/ld-window-main.c:149
msgid "Save _As..."
msgstr "Speichern _unter..."
#: ../src/ld-window-main.c:654
#, c-format
msgid ""
"Save the changes to diagram \"%s\" before closing it and creating a new one?"
msgstr "Änderungen im Diagramm \"%s\" speichern bevor ein Neues geöffnet wird?"
#: ../src/ld-window-main.c:786
#, c-format
msgid ""
"Save the changes to diagram \"%s\" before closing it and opening another one?"
msgstr ""
"Änderungen im Diagramm \"%s\" speichern bevor es beendet und ein Weiteres "
"geöffnet wird?"
#: ../src/ld-window-main.c:930
#, c-format
msgid "Save the changes to diagram \"%s\" before closing?"
msgstr "Änderungen im Diagramm \"%s\" vor dem Schließen speichern?"
#: ../src/ld-window-main.c:147
msgid "Save the current diagram"
msgstr "Speichern des aktuellen Diagramms"
#: ../src/ld-window-main.c:150
msgid "Save the current diagram with another name"
msgstr "Aktuelles Diagramm unter anderem Namen speichern"
#: ../src/ld-window-main.c:176
msgid "Select _All"
msgstr "_Alles Auswählen"
#: ../src/ld-window-main.c:177
msgid "Select all objects in the diagram"
msgstr "Alle Objekte im Diagramm auswählen"
#: ../src/ld-window-main.c:208
msgid "Show _Grid"
msgstr "_Gitter anzeigen"
#: ../src/ld-window-main.c:196
msgid "Show a dialog about this application"
msgstr "Zeige einen Dialog über diese Anwendung"
#: ../src/ld-window-main.c:209
msgid "Toggle displaying of the grid"
msgstr "Gitter ein-/ausblenden"
#: ../src/ld-window-main.c:206
msgid "Toggle displaying of the library pane"
msgstr "Bibliothek ein-/ausblenden"
#: ../src/ld-window-main.c:203
msgid "Toggle displaying of the main toolbar"
msgstr "Symbolleiste ein-/ausblenden"
#: ../src/ld-window-main.c:696
msgid "Try again or save it under another name."
msgstr "Erneuter Versuch oder unter anderem Namen speichern."
#: ../src/ld-window-main.c:163
msgid "Undo the last action"
msgstr "Letzte Aktion rückgangig machen"
#: ../src/ld-window-main.c:622
msgid "Unsaved Diagram"
msgstr "Ungespeichertes Diagramm"
#: ../src/ld-window-main.c:837
msgid "Untitled diagram"
msgstr "Unbenanntes Diagramm"
#: ../src/ld-window-main.c:184
msgid "Zoom _Out"
msgstr "Zoom _heraus"
#: ../src/ld-window-main.c:182
msgid "Zoom into the diagram"
msgstr "In das Diagramm zoomen"
#: ../src/ld-window-main.c:185
msgid "Zoom out of the diagram"
msgstr "Aus dem Diagramm zoomen"
#: ../src/logdiag.c:106
msgid "[FILE...]"
msgstr "[DATEI...]"
#: ../src/ld-window-main.c:195
msgid "_About"
msgstr "_Info"
#: ../src/ld-window-main.c:173
msgid "_Delete"
msgstr "_Löschen"
#: ../src/ld-window-main.c:161
msgid "_Edit"
msgstr "_Ändern"
#: ../src/ld-window-main.c:139
msgid "_File"
msgstr "_Datei"
#: ../src/ld-window-main.c:191
msgid "_Help"
msgstr "_Hilfe"
#: ../src/ld-window-main.c:205
msgid "_Library Pane"
msgstr "_Bibliothek Menüleiste"
#: ../src/ld-window-main.c:202
msgid "_Main Toolbar"
msgstr "_Symbolleiste"
#: ../src/ld-window-main.c:140
msgid "_New"
msgstr "_Neu"
#: ../src/ld-window-main.c:187
msgid "_Normal Size"
msgstr "_Normale Größe"
#: ../src/ld-window-main.c:143
msgid "_Open..."
msgstr "_Öffnen..."
#: ../src/ld-window-main.c:153
msgid "_Print..."
msgstr "_Drucken..."
#: ../src/ld-window-main.c:157
msgid "_Quit"
msgstr "_Beenden"
#: ../src/ld-window-main.c:165
msgid "_Redo"
msgstr "_Wiederholen"
#: ../src/ld-window-main.c:146
msgid "_Save"
msgstr "_Speichern"
#: ../src/ld-window-main.c:162
msgid "_Undo"
msgstr "_Rückgängig"
#: ../src/ld-window-main.c:192
msgid "_User Guide"
msgstr "_Benutzerhandbuch"
#: ../src/ld-window-main.c:180
msgid "_View"
msgstr "_Ansicht"
#: ../src/ld-window-main.c:181
msgid "_Zoom In"
msgstr "_Hineinzoomen"
#: ../src/ld-window-main.c:1163
msgid "translator-credits"
msgstr "Andy J."
#~ msgid "The file is probably corrupted."
#~ msgstr "Die Datei ist vermutlich beschädigt."

View File

@ -1,14 +1,14 @@
# SOME DESCRIPTIVE TITLE. # SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Přemysl Eric Janouch # Copyright (C) YEAR Přemysl Janouch
# This file is distributed under the same license as the logdiag package. # This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# #
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: logdiag 0.3.0\n" "Project-Id-Version: logdiag \n"
"Report-Msgid-Bugs-To: https://git.janouch.name/p/logdiag/issues\n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-10-28 20:07+0200\n" "POT-Creation-Date: 2011-02-13 20:25+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,257 +17,183 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: ../src/ld-window-main.c:139 #: ../src/ld-window-main.c:114
msgid "_File" msgid "_File"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:140 #: ../src/ld-window-main.c:115
msgid "_New" msgid "_New"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:141 #: ../src/ld-window-main.c:116
msgid "Create a new diagram" msgid "Create a new diagram"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:143 #: ../src/ld-window-main.c:118
msgid "_Open..." msgid "_Open..."
msgstr "" msgstr ""
#: ../src/ld-window-main.c:144 #: ../src/ld-window-main.c:119
msgid "Open a diagram" msgid "Open a diagram"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:146 #: ../src/ld-window-main.c:121
msgid "_Save" msgid "_Save"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:147 #: ../src/ld-window-main.c:122
msgid "Save the current diagram" msgid "Save the current diagram"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:149 #: ../src/ld-window-main.c:124
msgid "Save _As..." msgid "Save _As..."
msgstr "" msgstr ""
#: ../src/ld-window-main.c:150 #: ../src/ld-window-main.c:125
msgid "Save the current diagram with another name" msgid "Save the current diagram with another name"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:153 #: ../src/ld-window-main.c:132
msgid "_Print..."
msgstr ""
#: ../src/ld-window-main.c:154
msgid "Print the diagram"
msgstr ""
#: ../src/ld-window-main.c:157
msgid "_Quit" msgid "_Quit"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:158 #: ../src/ld-window-main.c:133
msgid "Quit the application" msgid "Quit the application"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:161 #: ../src/ld-window-main.c:136
msgid "_Edit" msgid "_Edit"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:162 #: ../src/ld-window-main.c:137
msgid "_Undo" msgid "_Undo"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:163 #: ../src/ld-window-main.c:138
msgid "Undo the last action" msgid "Undo the last action"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:165 #: ../src/ld-window-main.c:140
msgid "_Redo" msgid "_Redo"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:166 #: ../src/ld-window-main.c:141
msgid "Redo the last undone action" msgid "Redo the last undone action"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:173 #: ../src/ld-window-main.c:148
msgid "_Delete" msgid "_Delete"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:174 #: ../src/ld-window-main.c:149
msgid "Delete the contents of the selection" msgid "Delete the contents of the selection"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:176 #: ../src/ld-window-main.c:151
msgid "Select _All" msgid "Select _All"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:177 #: ../src/ld-window-main.c:152
msgid "Select all objects in the diagram" msgid "Select all objects in the diagram"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:180 #: ../src/ld-window-main.c:155
msgid "_View" msgid "_View"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:181 #: ../src/ld-window-main.c:156
msgid "_Zoom In" msgid "_Zoom In"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:182 #: ../src/ld-window-main.c:157
msgid "Zoom into the diagram" msgid "Zoom into the diagram"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:184 #: ../src/ld-window-main.c:159
msgid "Zoom _Out" msgid "Zoom _Out"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:185 #: ../src/ld-window-main.c:160
msgid "Zoom out of the diagram" msgid "Zoom out of the diagram"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:187 #: ../src/ld-window-main.c:162
msgid "_Normal Size" msgid "_Normal Size"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:188 #: ../src/ld-window-main.c:163
msgid "Reset zoom level back to the default" msgid "Reset zoom level back to the default"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:191 #: ../src/ld-window-main.c:166
msgid "_Help" msgid "_Help"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:192 #: ../src/ld-window-main.c:167
msgid "_User Guide"
msgstr ""
#: ../src/ld-window-main.c:193
msgid "Open the manual"
msgstr ""
#: ../src/ld-window-main.c:195
msgid "_About" msgid "_About"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:196 #: ../src/ld-window-main.c:168
msgid "Show a dialog about this application" msgid "Show a dialog about this application"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:202 #: ../src/ld-window-main.c:493
msgid "_Main Toolbar"
msgstr ""
#: ../src/ld-window-main.c:203
msgid "Toggle displaying of the main toolbar"
msgstr ""
#: ../src/ld-window-main.c:205
msgid "_Library Pane"
msgstr ""
#: ../src/ld-window-main.c:206
msgid "Toggle displaying of the library pane"
msgstr ""
#: ../src/ld-window-main.c:208
msgid "Show _Grid"
msgstr ""
#: ../src/ld-window-main.c:209
msgid "Toggle displaying of the grid"
msgstr ""
#: ../src/ld-window-main.c:370
msgid "Drag symbols from the library pane to add them to the diagram."
msgstr ""
#: ../src/ld-window-main.c:622
msgid "Unsaved Diagram" msgid "Unsaved Diagram"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:654 #: ../src/ld-window-main.c:525
#, c-format #, c-format
msgid "" msgid ""
"Save the changes to diagram \"%s\" before closing it and creating a new one?" "Save the changes to diagram \"%s\" before closing it and creating a new one?"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:693 #: ../src/ld-window-main.c:569
msgid "Failed to save the diagram" msgid "Failed to save the diagram"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:696 #: ../src/ld-window-main.c:572
msgid "Try again or save it under another name." msgid "Try again or save it under another name."
msgstr "" msgstr ""
#: ../src/ld-window-main.c:729 #: ../src/ld-window-main.c:604
msgid "Failed to open the file" msgid "Failed to open the file"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:738 #: ../src/ld-window-main.c:607
#, c-format msgid "The file is probably corrupted."
msgid "Failed to open file `%s': Invalid contents."
msgstr "" msgstr ""
#: ../src/ld-window-main.c:769 #: ../src/ld-window-main.c:629
msgid "Logdiag Diagrams (*.ldd)" msgid "Logdiag Diagrams (*.ldd)"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:786 #: ../src/ld-window-main.c:646
#, c-format #, c-format
msgid "" msgid ""
"Save the changes to diagram \"%s\" before closing it and opening another one?" "Save the changes to diagram \"%s\" before closing it and opening another one?"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:790 #: ../src/ld-window-main.c:650
msgid "Open..." msgid "Open..."
msgstr "" msgstr ""
#: ../src/ld-window-main.c:823 #: ../src/ld-window-main.c:681
msgid "Save As..." msgid "Save As..."
msgstr "" msgstr ""
#: ../src/ld-window-main.c:837 #: ../src/ld-window-main.c:734
msgid "Untitled diagram"
msgstr ""
#: ../src/ld-window-main.c:890
msgid "If you don't save, changes will be permanently lost." msgid "If you don't save, changes will be permanently lost."
msgstr "" msgstr ""
#: ../src/ld-window-main.c:892 #: ../src/ld-window-main.c:736
msgid "Close _without Saving" msgid "Close _without Saving"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:930 #: ../src/ld-window-main.c:774
#, c-format #, c-format
msgid "Save the changes to diagram \"%s\" before closing?" msgid "Save the changes to diagram \"%s\" before closing?"
msgstr "" msgstr ""
#: ../src/ld-window-main.c:968 #: ../src/logdiag.c:33
#, c-format msgid "[FILE] - Schematic editor"
msgid "%d%%"
msgstr ""
#: ../src/ld-window-main.c:1042
msgid "Error"
msgstr ""
#: ../src/ld-window-main.c:1149
msgid "Failed to open the user guide"
msgstr ""
#: ../src/ld-window-main.c:1163
msgid "translator-credits"
msgstr ""
#: ../src/logdiag.c:106
msgid "[FILE...]"
msgstr ""
#: ../src/logdiag.c:147
msgid "- Schematic editor"
msgstr ""
#: ../liblogdiag/ld-category-tree-view.c:138
msgid "Empty"
msgstr "" msgstr ""

View File

@ -1,21 +1,36 @@
#!/bin/sh -e #!/bin/sh
# This shell script generates the translation template. # This script makes a translation template
# # The reason for this not being inside CMakeLists.txt
# The reason for this not being inside CMakeLists.txt is that the translator # is that the translator should not need to run
# should not need to run the whole configuration process just to get this file. # the whole configure process to get this single stupid file.
dir=$(dirname $0)
export LC_ALL=C # Source files
SOURCES=$(echo ../{src,liblogdiag}/*.c)
re='^[ \t]*project *( *\([^ \t)]\{1,\}\) \{1,\}VERSION \{1,\}\([^ \t)]\{1,\}\).*' # Get the package name from CMakeLists.txt
package=$(sed -n "s/$re/\\1/p" "$dir/../CMakeLists.txt") PACKAGE=$(sed -n '/^[ \t]*[pP][rR][oO][jJ][eE][cC][tT][ \t]*([ \t]*\([^ \t)]\{1,\}\).*).*/{s//\1/p;q}' \
version=$(sed -n "s/$re/\\2/p" "$dir/../CMakeLists.txt") ../CMakeLists.txt)
if [ -z "$package" -o -z "$version" ]; then
echo "Failed to get information from CMakeLists.txt" # Get the package version from CMakeLists.txt
exit 1 EXP_BEG='/^[ \t]*[sS][eE][tT][ \t]*([ \t]*'$PACKAGE'_VERSION_'
EXP_END='[ \t]\{1,\}"\{0,1\}\([^)"]\{1,\}\)"\{0,1\}).*/{s//\1/p;q}'
MAJOR=$(sed -n "${EXP_BEG}MAJOR${EXP_END}" ../CMakeLists.txt)
MINOR=$(sed -n "${EXP_BEG}MINOR${EXP_END}" ../CMakeLists.txt)
PATCH=$(sed -n "${EXP_BEG}PATCH${EXP_END}" ../CMakeLists.txt)
if [ "$MAJOR" != "" ]; then
VERSION=$MAJOR
if [ "$MINOR" != "" ]; then
VERSION=$VERSION.$MINOR
if [ "$PATCH" != "" ]; then
VERSION=$VERSION.$PATCH
fi
fi
fi fi
xgettext -LC -k_ -kN_ "$dir"/../{src,liblogdiag}/*.c -o "$dir/$package.pot" \ # Finally make the template
--package-name="$package" --package-version="$version" \ xgettext -LC -k_ -kN_ $SOURCES -o "$PACKAGE".pot \
--copyright-holder="Přemysl Eric Janouch" \ --package-name="$PACKAGE" --package-version="$VERSION" \
--msgid-bugs-address="https://git.janouch.name/p/$package/issues" --copyright-holder="Přemysl Janouch"

274
po/pl.po
View File

@ -1,274 +0,0 @@
# Polish translation for logdiag.
# Copyright (C) 2011 Přemysl Eric Janouch
# This file is distributed under the same license as the logdiag package.
# Robert Svoboda <ravath@gmail.com>, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: logdiag\n"
"Report-Msgid-Bugs-To: https://git.janouch.name/p/logdiag/issues\n"
"POT-Creation-Date: 2021-10-28 20:07+0200\n"
"PO-Revision-Date: 2021-10-28 20:38+0200\n"
"Last-Translator: Přemysl Eric Janouch <p@janouch.name>\n"
"Language-Team: Polish <pl@li.org>\n"
"Language: pl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0\n"
#: ../src/ld-window-main.c:968
#, c-format
msgid "%d%%"
msgstr "%d%%"
#: ../src/logdiag.c:147
msgid "- Schematic editor"
msgstr "- Edytor schematów"
#: ../src/ld-window-main.c:892
msgid "Close _without Saving"
msgstr "Zamknąć _bez zapisu"
#: ../src/ld-window-main.c:141
msgid "Create a new diagram"
msgstr "Stworzenie nowego wykresu"
#: ../src/ld-window-main.c:174
msgid "Delete the contents of the selection"
msgstr "Usuń zawartość wyboru"
#: ../src/ld-window-main.c:370
msgid "Drag symbols from the library pane to add them to the diagram."
msgstr "Przeciągnij symbole z panelu biblioteki, aby dodać je do diagramu."
#: ../liblogdiag/ld-category-tree-view.c:138
msgid "Empty"
msgstr "Puste"
#: ../src/ld-window-main.c:1042
msgid "Error"
msgstr "Błąd"
#: ../src/ld-window-main.c:738
#, c-format
msgid "Failed to open file `%s': Invalid contents."
msgstr "Nie można otworzyć pliku \"%s\": Niepoprawna zawartość."
#: ../src/ld-window-main.c:729
msgid "Failed to open the file"
msgstr "Pliku nie da się otworzyć"
#: ../src/ld-window-main.c:1149
msgid "Failed to open the user guide"
msgstr "Przewodniku użytkownika nie da się otworzyć"
#: ../src/ld-window-main.c:693
msgid "Failed to save the diagram"
msgstr "Nie udało się zapisać wykresu"
#: ../src/ld-window-main.c:890
msgid "If you don't save, changes will be permanently lost."
msgstr "Jeżeli nie zapiszesz zmian, zostaną one trwale utracone."
#: ../src/ld-window-main.c:769
msgid "Logdiag Diagrams (*.ldd)"
msgstr "Wykresy logdiag (*.ldd)"
#: ../src/ld-window-main.c:144
msgid "Open a diagram"
msgstr "Otwórz wykres"
#: ../src/ld-window-main.c:193
msgid "Open the manual"
msgstr "Otworzy podręcznik"
#: ../src/ld-window-main.c:790
msgid "Open..."
msgstr "Otworzyć..."
#: ../src/ld-window-main.c:154
msgid "Print the diagram"
msgstr "Wydrukuje wykres"
#: ../src/ld-window-main.c:158
msgid "Quit the application"
msgstr "Zamknie aplikację"
#: ../src/ld-window-main.c:166
msgid "Redo the last undone action"
msgstr "Powtórzy ostatnio cofniętą akcję"
#: ../src/ld-window-main.c:188
msgid "Reset zoom level back to the default"
msgstr "Przywróci poziom zbliżenia na poziom wyjściowy"
#: ../src/ld-window-main.c:823
msgid "Save As..."
msgstr "Zapisz jako..."
#: ../src/ld-window-main.c:149
msgid "Save _As..."
msgstr "Zapisz _jako..."
#: ../src/ld-window-main.c:654
#, c-format
msgid "Save the changes to diagram \"%s\" before closing it and creating a new one?"
msgstr "Zapisać zmiany w wykresie \"%s\" przed jego zamknięciem i stworzeniem nowego?"
#: ../src/ld-window-main.c:786
#, c-format
msgid "Save the changes to diagram \"%s\" before closing it and opening another one?"
msgstr "Zapisać zmiany w wykresie \"%s\" przed jego zamknięciem i stworzeniem nowego?"
#: ../src/ld-window-main.c:930
#, c-format
msgid "Save the changes to diagram \"%s\" before closing?"
msgstr "Zapisać zmiany w wykresie \"%s\" przed jego zamknięciem?"
#: ../src/ld-window-main.c:147
msgid "Save the current diagram"
msgstr "Zapisz aktywny wykres"
#: ../src/ld-window-main.c:150
msgid "Save the current diagram with another name"
msgstr "Zapisać aktywny wykres pod inną nazwą"
#: ../src/ld-window-main.c:176
msgid "Select _All"
msgstr "Wybierz _wszystko"
#: ../src/ld-window-main.c:177
msgid "Select all objects in the diagram"
msgstr "Wybierze wszystkie obietky w wykresie"
#: ../src/ld-window-main.c:208
msgid "Show _Grid"
msgstr "Pokaż _siatkę"
#: ../src/ld-window-main.c:196
msgid "Show a dialog about this application"
msgstr "Pokaże informacje o tej aplikacji"
#: ../src/ld-window-main.c:209
msgid "Toggle displaying of the grid"
msgstr "Przełączy pokazywanie siatki"
#: ../src/ld-window-main.c:206
msgid "Toggle displaying of the library pane"
msgstr "Przełączy pokazywanie panelu biblioteki"
#: ../src/ld-window-main.c:203
msgid "Toggle displaying of the main toolbar"
msgstr "Przełączy pokazywanie głównego panelu narzędzi"
#: ../src/ld-window-main.c:696
msgid "Try again or save it under another name."
msgstr "Spróbuj ponownie, bądź zapisz pod inną nazwą."
#: ../src/ld-window-main.c:163
msgid "Undo the last action"
msgstr "Cofnie ostatnią akcję"
#: ../src/ld-window-main.c:622
msgid "Unsaved Diagram"
msgstr "Niezapisany wykres"
#: ../src/ld-window-main.c:837
msgid "Untitled diagram"
msgstr "Wykres bez nazwy"
#: ../src/ld-window-main.c:184
msgid "Zoom _Out"
msgstr "_Oddalić widok"
#: ../src/ld-window-main.c:182
msgid "Zoom into the diagram"
msgstr "Przybliżyć widok"
#: ../src/ld-window-main.c:185
msgid "Zoom out of the diagram"
msgstr "Oddalić widok"
#: ../src/logdiag.c:106
msgid "[FILE...]"
msgstr "[PLIK...]"
#: ../src/ld-window-main.c:195
msgid "_About"
msgstr "_O programie"
#: ../src/ld-window-main.c:173
msgid "_Delete"
msgstr "_Usuń"
#: ../src/ld-window-main.c:161
msgid "_Edit"
msgstr "_Edycja"
#: ../src/ld-window-main.c:139
msgid "_File"
msgstr "_Plik"
#: ../src/ld-window-main.c:191
msgid "_Help"
msgstr "_Pomoc"
#: ../src/ld-window-main.c:205
msgid "_Library Pane"
msgstr "Panel _biblioteki"
#: ../src/ld-window-main.c:202
msgid "_Main Toolbar"
msgstr "_Główny panel narzędzi"
#: ../src/ld-window-main.c:140
msgid "_New"
msgstr "_Nowy"
#: ../src/ld-window-main.c:187
msgid "_Normal Size"
msgstr "_Normalna wielkość"
#: ../src/ld-window-main.c:143
msgid "_Open..."
msgstr "_Otwórz..."
#: ../src/ld-window-main.c:153
msgid "_Print..."
msgstr "Wy_drukuj..."
#: ../src/ld-window-main.c:157
msgid "_Quit"
msgstr "_Zakończ"
#: ../src/ld-window-main.c:165
msgid "_Redo"
msgstr "_Powtórz"
#: ../src/ld-window-main.c:146
msgid "_Save"
msgstr "Z_apisz"
#: ../src/ld-window-main.c:162
msgid "_Undo"
msgstr "_Wróć"
#: ../src/ld-window-main.c:192
msgid "_User Guide"
msgstr "_Przewodnik użytkownika"
#: ../src/ld-window-main.c:180
msgid "_View"
msgstr "_Widok"
#: ../src/ld-window-main.c:181
msgid "_Zoom In"
msgstr "_Przybliżyć"
#: ../src/ld-window-main.c:1163
msgid "translator-credits"
msgstr "Robert Svoboda <ravath@gmail.com>"
#~ msgid "The file is probably corrupted."
#~ msgstr "Plik jest prawdopodobnie uszkodzony."

274
po/sk.po
View File

@ -1,274 +0,0 @@
# Slovak translation for logdiag.
# Copyright (C) 2011 Přemysl Eric Janouch
# This file is distributed under the same license as the logdiag package.
# Miroslav Rigler <itsgoingd@luzer.sk>, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: logdiag\n"
"Report-Msgid-Bugs-To: https://git.janouch.name/p/logdiag/issues\n"
"POT-Creation-Date: 2021-10-28 20:07+0200\n"
"PO-Revision-Date: 2021-10-28 20:23+0200\n"
"Last-Translator: Přemysl Eric Janouch <p@janouch.name>\n"
"Language-Team: Slovak <sk@li.org>\n"
"Language: sk\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0\n"
#: ../src/ld-window-main.c:968
#, c-format
msgid "%d%%"
msgstr "%d %%"
#: ../src/logdiag.c:147
msgid "- Schematic editor"
msgstr "- Editor schém"
#: ../src/ld-window-main.c:892
msgid "Close _without Saving"
msgstr "Zatvoriť _bez uloženia"
#: ../src/ld-window-main.c:141
msgid "Create a new diagram"
msgstr "Vytvorí nový diagram"
#: ../src/ld-window-main.c:174
msgid "Delete the contents of the selection"
msgstr "Odstráni obsah výberu"
#: ../src/ld-window-main.c:370
msgid "Drag symbols from the library pane to add them to the diagram."
msgstr "Pre pridanie symbolov do diagramu ich pretiahnite z panela knižnice."
#: ../liblogdiag/ld-category-tree-view.c:138
msgid "Empty"
msgstr "Prázdne"
#: ../src/ld-window-main.c:1042
msgid "Error"
msgstr "Chyba"
#: ../src/ld-window-main.c:738
#, c-format
msgid "Failed to open file `%s': Invalid contents."
msgstr "Nepodarilo sa otvoriť súbor \"%s\": Neplatný obsah."
#: ../src/ld-window-main.c:729
msgid "Failed to open the file"
msgstr "Nepodarilo sa otvoriť súbor"
#: ../src/ld-window-main.c:1149
msgid "Failed to open the user guide"
msgstr "Nepodarilo sa otvoriť príručku používateľa"
#: ../src/ld-window-main.c:693
msgid "Failed to save the diagram"
msgstr "Nepodarilo sa uložiť diagram"
#: ../src/ld-window-main.c:890
msgid "If you don't save, changes will be permanently lost."
msgstr "Ak ich neuložíte, budú zmeny navždy stratené."
#: ../src/ld-window-main.c:769
msgid "Logdiag Diagrams (*.ldd)"
msgstr "Diagramy logdiag (*.ldd)"
#: ../src/ld-window-main.c:144
msgid "Open a diagram"
msgstr "Otvorí diagram"
#: ../src/ld-window-main.c:193
msgid "Open the manual"
msgstr "Otvorí manuál"
#: ../src/ld-window-main.c:790
msgid "Open..."
msgstr "Otvoriť..."
#: ../src/ld-window-main.c:154
msgid "Print the diagram"
msgstr "Vytlačí diagram"
#: ../src/ld-window-main.c:158
msgid "Quit the application"
msgstr "Ukončí aplikáciu"
#: ../src/ld-window-main.c:166
msgid "Redo the last undone action"
msgstr "Vykoná naposledy vrátenú akciu"
#: ../src/ld-window-main.c:188
msgid "Reset zoom level back to the default"
msgstr "Vráti priblíženie na východiskovú hodnotu"
#: ../src/ld-window-main.c:823
msgid "Save As..."
msgstr "Uložiť ako..."
#: ../src/ld-window-main.c:149
msgid "Save _As..."
msgstr "Uložiť _ako..."
#: ../src/ld-window-main.c:654
#, c-format
msgid "Save the changes to diagram \"%s\" before closing it and creating a new one?"
msgstr "Uložiť zmeny v diagrame \"%s\" pred jeho zatvorením a vytvorením nového?"
#: ../src/ld-window-main.c:786
#, c-format
msgid "Save the changes to diagram \"%s\" before closing it and opening another one?"
msgstr "Uložiť zmeny v diagrame \"%s\" pred jeho zatvorením a otvorením iného?"
#: ../src/ld-window-main.c:930
#, c-format
msgid "Save the changes to diagram \"%s\" before closing?"
msgstr "Uložiť zmeny v diagrame \"%s\" pred jeho zatvorením?"
#: ../src/ld-window-main.c:147
msgid "Save the current diagram"
msgstr "Uloží aktuálny diagram"
#: ../src/ld-window-main.c:150
msgid "Save the current diagram with another name"
msgstr "Uloží aktuálny diagram pod iným menom"
#: ../src/ld-window-main.c:176
msgid "Select _All"
msgstr "Vybrať _všetko"
#: ../src/ld-window-main.c:177
msgid "Select all objects in the diagram"
msgstr "Vyberie všetky objekty v diagrame"
#: ../src/ld-window-main.c:208
msgid "Show _Grid"
msgstr "Zobraziť _mriežku"
#: ../src/ld-window-main.c:196
msgid "Show a dialog about this application"
msgstr "Zobrazí dialóg o tejto aplikácii"
#: ../src/ld-window-main.c:209
msgid "Toggle displaying of the grid"
msgstr "Prepne zobrazovanie mriežky"
#: ../src/ld-window-main.c:206
msgid "Toggle displaying of the library pane"
msgstr "Prepne zobrazovanie panelu knižnice"
#: ../src/ld-window-main.c:203
msgid "Toggle displaying of the main toolbar"
msgstr "Prepne zobrazovanie hlavného panelu nástrojov"
#: ../src/ld-window-main.c:696
msgid "Try again or save it under another name."
msgstr "Skúste to znova alebo ho uložte pod iným názvom."
#: ../src/ld-window-main.c:163
msgid "Undo the last action"
msgstr "Vráti poslednú akciu"
#: ../src/ld-window-main.c:622
msgid "Unsaved Diagram"
msgstr "Neuložený diagram"
#: ../src/ld-window-main.c:837
msgid "Untitled diagram"
msgstr "Nepomenovaný diagram"
#: ../src/ld-window-main.c:184
msgid "Zoom _Out"
msgstr "_Oddialiť"
#: ../src/ld-window-main.c:182
msgid "Zoom into the diagram"
msgstr "Priblíži diagram"
#: ../src/ld-window-main.c:185
msgid "Zoom out of the diagram"
msgstr "Oddiali diagram"
#: ../src/logdiag.c:106
msgid "[FILE...]"
msgstr "[SÚBOR...]"
#: ../src/ld-window-main.c:195
msgid "_About"
msgstr "_O programe"
#: ../src/ld-window-main.c:173
msgid "_Delete"
msgstr "_Zmazať"
#: ../src/ld-window-main.c:161
msgid "_Edit"
msgstr "_Úpravy"
#: ../src/ld-window-main.c:139
msgid "_File"
msgstr "_Súbor"
#: ../src/ld-window-main.c:191
msgid "_Help"
msgstr "_Nápoveda"
#: ../src/ld-window-main.c:205
msgid "_Library Pane"
msgstr "Panel _knižnice"
#: ../src/ld-window-main.c:202
msgid "_Main Toolbar"
msgstr "_Hlavný panel nástrojov"
#: ../src/ld-window-main.c:140
msgid "_New"
msgstr "_Nový"
#: ../src/ld-window-main.c:187
msgid "_Normal Size"
msgstr "_Normálna veľkosť"
#: ../src/ld-window-main.c:143
msgid "_Open..."
msgstr "_Otvoriť..."
#: ../src/ld-window-main.c:153
msgid "_Print..."
msgstr "_Tlačiť..."
#: ../src/ld-window-main.c:157
msgid "_Quit"
msgstr "U_končiť"
#: ../src/ld-window-main.c:165
msgid "_Redo"
msgstr "Z_novu"
#: ../src/ld-window-main.c:146
msgid "_Save"
msgstr "_Uložiť"
#: ../src/ld-window-main.c:162
msgid "_Undo"
msgstr "_Späť"
#: ../src/ld-window-main.c:192
msgid "_User Guide"
msgstr "_Príručka používateľa"
#: ../src/ld-window-main.c:180
msgid "_View"
msgstr "_Zobrazenie"
#: ../src/ld-window-main.c:181
msgid "_Zoom In"
msgstr "_Priblížiť"
#: ../src/ld-window-main.c:1163
msgid "translator-credits"
msgstr "Miroslav Rigler <itsgoingd@luzer.sk>"
#~ msgid "The file is probably corrupted."
#~ msgstr "Súbor je pravdepodobne poškodený."

View File

@ -1,16 +1,18 @@
<ui> <ui>
<menubar name="MenuBar"> <menubar name="MenuBar">
<menu action="FileMenu"> <menu name="FileMenu" action="FileMenu">
<menuitem action="New" /> <menuitem action="New" />
<menuitem action="Open" /> <menuitem action="Open" />
<menuitem action="Save" /> <menuitem action="Save" />
<menuitem action="SaveAs" /> <menuitem action="SaveAs" />
<separator /> <separator />
<menuitem action="Print" /> <!--
<menuitem action="Export" />
<separator /> <separator />
-->
<menuitem action="Quit" /> <menuitem action="Quit" />
</menu> </menu>
<menu action="EditMenu"> <menu name="EditMenu" action="EditMenu">
<menuitem action="Undo" /> <menuitem action="Undo" />
<menuitem action="Redo" /> <menuitem action="Redo" />
<separator /> <separator />
@ -23,18 +25,12 @@
<separator /> <separator />
<menuitem action="SelectAll" /> <menuitem action="SelectAll" />
</menu> </menu>
<menu action="ViewMenu"> <menu name="ViewMenu" action="ViewMenu">
<menuitem action="MainToolbar" />
<menuitem action="LibraryPane" />
<separator />
<menuitem action="ShowGrid" />
<separator />
<menuitem action="ZoomIn" /> <menuitem action="ZoomIn" />
<menuitem action="ZoomOut" /> <menuitem action="ZoomOut" />
<menuitem action="NormalSize" /> <menuitem action="NormalSize" />
</menu> </menu>
<menu action="HelpMenu"> <menu name="HelpMenu" action="HelpMenu">
<menuitem action="UserGuide" />
<menuitem action="About" /> <menuitem action="About" />
</menu> </menu>
</menubar> </menubar>

View File

@ -2,19 +2,13 @@
local names_npn = local names_npn =
{ {
en = "NPN transistor", en = "NPN transistor",
cs = "Tranzistor NPN", cs = "Tranzistor NPN"
sk = "Tranzistor NPN",
pl = "Tranzystor NPN",
de = "NPN Transistor"
} }
local names_pnp = local names_pnp =
{ {
en = "PNP transistor", en = "PNP transistor",
cs = "Tranzistor PNP", cs = "Tranzistor PNP"
sk = "Tranzistor PNP",
pl = "Tranzystor PNP",
de = "PNP Transistor"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -26,50 +20,50 @@ local terminals = {{-2, 0}, {2, 2}, {2, -2}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The terminals -- The terminals
cr:move_to (-2, 0) cr.move_to (-2, 0)
cr:line_to (0, 0) cr.line_to (0, 0)
cr:move_to (0, 0.5) cr.move_to (0, 0.5)
cr:line_to (2, 2) cr.line_to (2, 2)
cr:move_to (0, -0.5) cr.move_to (0, -0.5)
cr:line_to (2, -2) cr.line_to (2, -2)
-- The ohmic connection -- The ohmic connection
cr:move_to (0, -1) cr.move_to (0, -1)
cr:line_to (0, 1) cr.line_to (0, 1)
cr:stroke () cr.stroke ()
end end
local render_npn = function (cr) local render_npn = function (cr)
render (cr) render (cr)
cr:save () cr.save ()
cr:translate (0, 0.5) cr.translate (0, 0.5)
cr:rotate (math.atan2 (-2, 1.5)) cr.rotate (math.atan2 (-2, 1.5))
cr:move_to (-0.4, 0.8) cr.move_to (-0.4, 0.8)
cr:line_to (0, 1.4) cr.line_to (0, 1.4)
cr:line_to (0.4, 0.8) cr.line_to (0.4, 0.8)
cr:stroke () cr.stroke ()
cr:restore () cr.restore ()
end end
local render_pnp = function (cr) local render_pnp = function (cr)
render (cr) render (cr)
cr:save () cr.save ()
cr:translate (2, -2) cr.translate (2, -2)
cr:rotate (math.atan2 (2, 1.5)) cr.rotate (math.atan2 (2, 1.5))
cr:move_to (-0.4, 1.3) cr.move_to (-0.4, 1.3)
cr:line_to (0, 1.9) cr.line_to (0, 1.9)
cr:line_to (0.4, 1.3) cr.line_to (0.4, 1.3)
cr:stroke () cr.stroke ()
cr:restore () cr.restore ()
end end
-- Register the symbols -- Register the symbols

View File

@ -1,8 +1,5 @@
{ {
"en": "Active", "en": "Active",
"cs": "Aktivní", "cs": "Aktivní"
"sk": "Aktívne",
"pl": "Aktywne",
"de": "Aktiv"
} }

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="128"
height="128"
id="svg2">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(-3,-1)"
id="g3774"
style="fill:none;stroke:#000000;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none">
<path
d="m 20,63 45,0"
id="path3764"
style="fill:none;stroke:#000000;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 65,38 0,50"
id="path3766"
style="fill:none;stroke:#000000;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="M 65,53 110,23"
id="path3768"
style="fill:none;stroke:#000000;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 65,73 45,30"
id="path3770"
style="fill:none;stroke:#000000;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="M 78,92 93,92 88,77"
id="path3772"
style="fill:none;stroke:#000000;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -2,19 +2,13 @@
local names_n = local names_n =
{ {
en = "N-channel IGFET transistor", en = "N-channel IGFET transistor",
cs = "Tranzistor IGFET s kanálem N", cs = "Tranzistor IGFET s kanálem N"
sk = "Tranzistor IGFET s kanálom N",
pl = "Tranzystor IGFET z kanałem N",
de = "N-Kanal IGFET Transistor"
} }
local names_p = local names_p =
{ {
en = "P-channel IGFET transistor", en = "P-channel IGFET transistor",
cs = "Tranzistor IGFET s kanálem P", cs = "Tranzistor IGFET s kanálem P"
sk = "Tranzistor IGFET s kanálom P",
pl = "Tranzystor IGFET z kanałem P",
de = "P-Kanal IGFET Transistor"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -27,59 +21,59 @@ local terminals_p = {{-2, -1}, {2, 1}, {2, 0}, {2, -1}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The terminals -- The terminals
cr:move_to (-0.3, 1) cr.move_to (-0.3, 1)
cr:line_to (-0.3, -1) cr.line_to (-0.3, -1)
cr:move_to (0, 1) cr.move_to (0, 1)
cr:line_to (2, 1) cr.line_to (2, 1)
cr:move_to (0, 0) cr.move_to (0, 0)
cr:line_to (2, 0) cr.line_to (2, 0)
cr:move_to (0, -1) cr.move_to (0, -1)
cr:line_to (2, -1) cr.line_to (2, -1)
-- Source, gate, drain -- Source, gate, drain
cr:move_to (0, -1.5) cr.move_to (0, -1.5)
cr:line_to (0, -0.5) cr.line_to (0, -0.5)
cr:move_to (0, -0.3) cr.move_to (0, -0.3)
cr:line_to (0, 0.3) cr.line_to (0, 0.3)
cr:move_to (0, 0.5) cr.move_to (0, 0.5)
cr:line_to (0, 1.5) cr.line_to (0, 1.5)
cr:stroke () cr.stroke ()
end end
local render_n = function (cr) local render_n = function (cr)
render (cr) render (cr)
-- The left-side terminal -- The left-side terminal
cr:move_to (-2, 1) cr.move_to (-2, 1)
cr:line_to (-0.3, 1) cr.line_to (-0.3, 1)
-- The arrow -- The arrow
cr:move_to (0.9, -0.4) cr.move_to (0.9, -0.4)
cr:line_to (0.4, 0) cr.line_to (0.4, 0)
cr:line_to (0.9, 0.4) cr.line_to (0.9, 0.4)
cr:stroke () cr.stroke ()
end end
local render_p = function (cr) local render_p = function (cr)
render (cr) render (cr)
-- The left-side terminal -- The left-side terminal
cr:move_to (-2, -1) cr.move_to (-2, -1)
cr:line_to (-0.3, -1) cr.line_to (-0.3, -1)
-- The arrow -- The arrow
cr:move_to (0.4, -0.4) cr.move_to (0.4, -0.4)
cr:line_to (0.9, 0) cr.line_to (0.9, 0)
cr:line_to (0.4, 0.4) cr.line_to (0.4, 0.4)
cr:stroke () cr.stroke ()
end end
-- Register the symbols -- Register the symbols

View File

@ -2,19 +2,13 @@
local names_n = local names_n =
{ {
en = "N-channel JFET transistor", en = "N-channel JFET transistor",
cs = "Tranzistor JFET s kanálem N", cs = "Tranzistor JFET s kanálem N"
sk = "Tranzistor JFET s kanálom N",
pl = "Tranzystor JFET z kanałem N",
de = "N-Kanal JFET Transistor"
} }
local names_p = local names_p =
{ {
en = "P-channel JFET transistor", en = "P-channel JFET transistor",
cs = "Tranzistor JFET s kanálem P", cs = "Tranzistor JFET s kanálem P"
sk = "Tranzistor JFET s kanálom P",
pl = "Tranzystor JFET z kanałem P",
de = "P-Kanal JFET Transistor"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -27,47 +21,47 @@ local terminals_p = {{-2, -1}, {2, 1}, {2, -1}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The terminals -- The terminals
cr:move_to (0, 1) cr.move_to (0, 1)
cr:line_to (2, 1) cr.line_to (2, 1)
cr:move_to (0, -1) cr.move_to (0, -1)
cr:line_to (2, -1) cr.line_to (2, -1)
-- The ohmic connection -- The ohmic connection
cr:move_to (0, -1.5) cr.move_to (0, -1.5)
cr:line_to (0, 1.5) cr.line_to (0, 1.5)
cr:stroke () cr.stroke ()
end end
local render_n = function (cr) local render_n = function (cr)
render (cr) render (cr)
-- The left-side terminal -- The left-side terminal
cr:move_to (-2, 1) cr.move_to (-2, 1)
cr:line_to (0, 1) cr.line_to (0, 1)
-- The arrow -- The arrow
cr:move_to (-1, 0.6) cr.move_to (-1, 0.6)
cr:line_to (-0.5, 1) cr.line_to (-0.5, 1)
cr:line_to (-1, 1.4) cr.line_to (-1, 1.4)
cr:stroke () cr.stroke ()
end end
local render_p = function (cr) local render_p = function (cr)
render (cr) render (cr)
-- The left-side terminal -- The left-side terminal
cr:move_to (-2, -1) cr.move_to (-2, -1)
cr:line_to (0, -1) cr.line_to (0, -1)
-- The arrow -- The arrow
cr:move_to (-0.4, -0.6) cr.move_to (-0.4, -0.6)
cr:line_to (-1, -1) cr.line_to (-1, -1)
cr:line_to (-0.4, -1.4) cr.line_to (-0.4, -1.4)
cr:stroke () cr.stroke ()
end end
-- Register the symbols -- Register the symbols

View File

@ -2,10 +2,7 @@
local names = local names =
{ {
en = "AND", en = "AND",
cs = "AND", cs = "AND"
sk = "AND",
pl = "AND",
de = "UND"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -17,23 +14,23 @@ local terminals = {{-4, -1}, {-4, 1}, {5, 0}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The main shape -- The main shape
cr:move_to (-2, -2) cr.move_to (-2, -2)
cr:line_to (1, -2) cr.line_to (1, -2)
cr:arc (1, 0, 2, math.pi * 1.5, math.pi * 0.5) cr.arc (1, 0, 2, math.pi * 1.5, math.pi * 0.5)
cr:line_to (-2, 2) cr.line_to (-2, 2)
cr:close_path () cr.close_path ()
-- The terminals -- The terminals
cr:move_to (-4, -1) cr.move_to (-4, -1)
cr:line_to (-2, -1) cr.line_to (-2, -1)
cr:move_to (-4, 1) cr.move_to (-4, 1)
cr:line_to (-2, 1) cr.line_to (-2, 1)
cr:move_to (3, 0) cr.move_to (3, 0)
cr:line_to (5, 0) cr.line_to (5, 0)
cr:stroke () cr.stroke ()
end end
-- Register the symbol -- Register the symbol

View File

@ -1,7 +1,5 @@
{ {
"en": "Logical", "en": "Logical",
"cs": "Logické", "cs": "Logické"
"sk": "Logické",
"pl": "Logiczne"
} }

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="128"
height="128"
id="svg2">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-924.36218)"
id="layer1">
<g
transform="translate(-10,-60)"
id="g3016">
<path
d="m 25,1030.3622 20,0"
id="path3008"
style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 25,1014.3622 20,0"
id="path3010"
style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 45,118 0,-40 25,0 c 0,0 20,0 20,20 0,20 -20,20 -20,20 z"
transform="translate(0,924.36218)"
id="path3012"
style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 90,98 20,0"
transform="translate(0,924.36218)"
id="path3014"
style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
</g>
<g
transform="translate(5,-5)"
id="g3016-8">
<path
d="m 25,1022.3622 20,0"
id="path3010-0"
style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="M 45,118 45,78 75,98 z"
transform="translate(0,924.36218)"
id="path3012-9"
style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 87.5,1022.3622 17.5,0"
id="path3014-6"
style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 100,93 a 10,10 0 1 1 -20,0 10,10 0 1 1 20,0 z"
transform="matrix(0.5,0,0,0.5,37,975.86218)"
id="path3820"
style="fill:none;stroke:#000000;stroke-width:8;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -2,10 +2,7 @@
local names = local names =
{ {
en = "NOT", en = "NOT",
cs = "NOT", cs = "NOT"
sk = "NOT",
pl = "NOT",
de = "NICHT"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -17,23 +14,23 @@ local terminals = {{-4, 0}, {4, 0}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The triangle -- The triangle
cr:move_to (-2, -2) cr.move_to (-2, -2)
cr:line_to (2, 0) cr.line_to (2, 0)
cr:line_to (-2, 2) cr.line_to (-2, 2)
cr:close_path () cr.close_path ()
-- The circle -- The circle
cr:new_sub_path () cr.new_sub_path ()
cr:arc (2.25, 0, 0.25, 0, 2 * math.pi) cr.arc (2.25, 0, 0.25, 0, 2 * math.pi)
-- The terminals -- The terminals
cr:move_to (-4, 0) cr.move_to (-4, 0)
cr:line_to (-2, 0) cr.line_to (-2, 0)
cr:move_to (2.5, 0) cr.move_to (2.5, 0)
cr:line_to (4, 0) cr.line_to (4, 0)
cr:stroke () cr.stroke ()
end end
-- Register the symbol -- Register the symbol

View File

@ -2,10 +2,7 @@
local names = local names =
{ {
en = "OR", en = "OR",
cs = "OR", cs = "OR"
sk = "OR",
pl = "OR",
de = "ODER"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -17,39 +14,38 @@ local terminals = {{-4, -1}, {-4, 1}, {5, 0}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The main shape -- The main shape
cr:move_to (-2, -2) cr.move_to (-2, -2)
cr:line_to (0, -2) cr.line_to (0, -2)
cr:curve_to (2, -2, 3, 0, 3, 0) cr.curve_to (2, -2, 3, 0, 3, 0)
cr:curve_to (3, 0, 2, 2, 0, 2) cr.curve_to (3, 0, 2, 2, 0, 2)
cr:line_to (-2, 2) cr.line_to (-2, 2)
cr:curve_to (-1, 1, -1, -1, -2, -2) cr.curve_to (-1, 1, -1, -1, -2, -2)
cr:close_path () cr.stroke ()
cr:stroke ()
-- The terminals -- The terminals
cr:save () cr.save ()
-- Crop the contacts according to -- Crop the contacts according to
-- the left side of the main shape -- the left side of the main shape
cr:move_to (-4, 2) cr.move_to (-4, 2)
cr:line_to (-2, 2) cr.line_to (-2, 2)
cr:curve_to (-1, 1, -1, -1, -2, -2) cr.curve_to (-1, 1, -1, -1, -2, -2)
cr:line_to (-4, -2) cr.line_to (-4, -2)
cr:close_path () cr.close_path ()
cr:clip () cr.clip ()
cr:move_to (-4, -1) cr.move_to (-4, -1)
cr:line_to (-1, -1) cr.line_to (-1, -1)
cr:move_to (-4, 1) cr.move_to (-4, 1)
cr:line_to (-1, 1) cr.line_to (-1, 1)
cr:stroke () cr.stroke ()
cr:restore () cr.restore ()
cr:move_to (3, 0) cr.move_to (3, 0)
cr:line_to (5, 0) cr.line_to (5, 0)
cr:stroke () cr.stroke ()
end end
-- Register the symbol -- Register the symbol

View File

@ -1,8 +1,5 @@
{ {
"en": "Miscellaneous", "en": "Miscellaneous",
"cs": "Smíšené", "cs": "Smíšené"
"sk": "Zmiešané",
"pl": "Różne",
"de": "Diverse"
} }

View File

@ -2,10 +2,7 @@
local names = local names =
{ {
en = "Cell", en = "Cell",
cs = "Článek", cs = "Článek"
sk = "Článok",
pl = "Ogniwo",
de = "Zelle"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -17,20 +14,20 @@ local terminals = {{-1, 0}, {1, 0}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The vertical lines -- The vertical lines
cr:move_to (-0.2, -1) cr.move_to (-0.2, -1)
cr:line_to (-0.2, 1) cr.line_to (-0.2, 1)
cr:move_to (0.2, -2) cr.move_to (0.2, -2)
cr:line_to (0.2, 2) cr.line_to (0.2, 2)
-- The terminals -- The terminals
cr:move_to (-1, 0) cr.move_to (-1, 0)
cr:line_to (-0.2, 0) cr.line_to (-0.2, 0)
cr:move_to (0.2, 0) cr.move_to (0.2, 0)
cr:line_to (1, 0) cr.line_to (1, 0)
cr:stroke () cr.stroke ()
end end
-- Register the symbol -- Register the symbol

View File

@ -2,10 +2,7 @@
local names = local names =
{ {
en = "Ground", en = "Ground",
cs = "Zem", cs = "Zem"
sk = "Uzemnenie",
pl = "Ziemia",
de = "Masse"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -17,20 +14,20 @@ local terminals = {{0, -1}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The vertical line -- The vertical line
cr:move_to (0, -1) cr.move_to (0, -1)
cr:line_to (0, 0.5) cr.line_to (0, 0.5)
-- The horizontal lines -- The horizontal lines
cr:move_to (-1, 0.5) cr.move_to (-1, 0.5)
cr:line_to (1, 0.5) cr.line_to (1, 0.5)
cr:move_to (-0.75, 1.1) cr.move_to (-0.75, 1.1)
cr:line_to (0.75, 1.1) cr.line_to (0.75, 1.1)
cr:move_to (-0.5, 1.7) cr.move_to (-0.5, 1.7)
cr:line_to (0.5, 1.7) cr.line_to (0.5, 1.7)
cr:stroke () cr.stroke ()
end end
-- Register the symbol -- Register the symbol

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="128"
height="128"
id="svg2">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="g3837">
<g
transform="translate(120,-10)"
id="g3771"
style="fill:none">
<path
d="m 140,48 a 25,25 0 1 1 -50,0 25,25 0 1 1 50,0 z"
transform="translate(-180,0)"
id="path2991"
style="stroke:#000000;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m -90,48 -15,0"
id="path3761"
style="stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m -40,48 15,0"
id="path3763"
style="stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m -80,33 30,30"
id="path3767"
style="stroke:#000000;stroke-width:4;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="M -50,33 -80,63"
id="path3769"
style="stroke:#000000;stroke-width:4;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
</g>
<g
transform="translate(0,5)"
id="g3786"
style="fill:none">
<path
d="m 90,57 0,20"
id="path3778"
style="stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 65,77 50,0"
id="path3780"
style="stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 70,93 40,0"
id="path3782"
style="stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 75,109 30,0"
id="path3784"
style="stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -2,10 +2,7 @@
local names = local names =
{ {
en = "Junction", en = "Junction",
cs = "Spoj", cs = "Spoj"
sk = "Spoj",
pl = "Złącze",
de = "Anschluss"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -17,8 +14,8 @@ local terminals = {}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The disk -- The disk
cr:arc (0, 0, 0.3, 0, math.pi * 2) cr.arc (0, 0, 0.3, 0, math.pi * 2)
cr:fill () cr.fill ()
end end
-- Register the symbol -- Register the symbol

View File

@ -2,10 +2,7 @@
local names = local names =
{ {
en = "Lamp", en = "Lamp",
cs = "Světelný zdroj", cs = "Světelný zdroj"
sk = "Svetelný zdroj",
pl = "Źródło światła",
de = "Lampe"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -17,29 +14,29 @@ local terminals = {{-2, 0}, {2, 0}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The circle -- The circle
cr:save () cr.save ()
cr:arc (0, 0, 1, 0, 2 * math.pi) cr.arc (0, 0, 1, 0, 2 * math.pi)
cr:stroke_preserve () cr.stroke_preserve ()
cr:clip () cr.clip ()
cr:move_to (-1, -1) cr.move_to (-1, -1)
cr:line_to (1, 1) cr.line_to (1, 1)
cr:move_to (1, -1) cr.move_to (1, -1)
cr:line_to (-1, 1) cr.line_to (-1, 1)
cr:stroke () cr.stroke ()
cr:restore () cr.restore ()
-- The terminals -- The terminals
cr:move_to (-2, 0) cr.move_to (-2, 0)
cr:line_to (-1, 0) cr.line_to (-1, 0)
cr:move_to (1, 0) cr.move_to (1, 0)
cr:line_to (2, 0) cr.line_to (2, 0)
cr:stroke () cr.stroke ()
end end
-- Register the symbol -- Register the symbol

View File

@ -2,83 +2,82 @@
local names_A = local names_A =
{ {
en = "Ammeter", en = "Ammeter",
cs = "Ampérmetr", cs = "Ampérmetr"
sk = "Ampérmeter", }
pl = "Amperomierz",
de = "Ampermeter" local names_mA =
{
en = "Milliammeter",
cs = "Miliampérmetr"
} }
local names_V = local names_V =
{ {
en = "Voltmeter", en = "Voltmeter",
cs = "Voltmetr", cs = "Voltmetr"
sk = "Voltmeter",
pl = "Woltomierz",
de = "Voltmeter"
} }
local names_ohm = local names_ohm =
{ {
en = "Ohmmeter", en = "Ohmmeter",
cs = "Ohmmetr", cs = "Ohmmetr"
sk = "Ohmmeter", }
pl = "Omomierz",
de = "Ohmmeter" local names_W =
{
en = "Wattmeter",
cs = "Wattmetr"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
local area = {-2, -2, 2, 2} local area = {-3, -2, 3, 2}
-- Terminal points -- Terminal points
local terminals = {{-2, 0}, {2, 0}, {0, -2}, {0, 2}} local terminals = {{-3, 0}, {3, 0}}
-- Rendering -- Rendering
local render_A = function (cr) local render = function (cr, name)
-- The circle -- The circle
cr:arc (0, 0, 2, 0, math.pi * 2) cr.arc (0, 0, 2, 0, math.pi * 2)
-- The letter A -- The contact
cr:move_to (-0.4, 0.5) cr.move_to (-3, 0)
cr:line_to (0, -0.5) cr.line_to (-2, 0)
cr:line_to (0.4, 0.5)
cr:move_to (-0.3, 0.25) cr.move_to (2, 0)
cr:line_to (0.3, 0.25) cr.line_to (3, 0)
cr:stroke () cr.stroke ()
cr.move_to (0, 0)
cr.show_text (name)
end
local render_A = function (cr)
render (cr, "A")
end
local render_mA = function (cr)
render (cr, "mA")
end end
local render_V = function (cr) local render_V = function (cr)
-- The circle render (cr, "V")
cr:arc (0, 0, 2, 0, math.pi * 2)
-- The letter V
cr:move_to (-0.4, -0.5)
cr:line_to (0, 0.5)
cr:line_to (0.4, -0.5)
cr:stroke ()
end end
local render_ohm = function (cr) local render_ohm = function (cr)
-- The circle render (cr, "")
cr:arc (0, 0, 2, 0, math.pi * 2) end
-- The capital letter omega local render_W = function (cr)
cr:move_to (-0.5, 0.5) render (cr, "W")
cr:line_to (-0.15, 0.5)
cr:curve_to (-0.15, 0.5, -0.4, 0.3, -0.4, 0)
cr:curve_to (-0.4, -0.25, -0.25, -0.5, 0, -0.5)
cr:curve_to (0.25, -0.5, 0.4, -0.25, 0.4, 0)
cr:curve_to (0.4, 0.3, 0.15, 0.5, 0.15, 0.5)
cr:line_to (0.5, 0.5)
cr:stroke ()
end end
-- Register the symbols -- Register the symbols
logdiag.register ("Ammeter", names_A, area, terminals, render_A) logdiag.register ("Ammeter", names_A, area, terminals, render_A)
logdiag.register ("Milliammeter", names_mA, area, terminals, render_mA)
logdiag.register ("Voltmeter", names_V, area, terminals, render_V) logdiag.register ("Voltmeter", names_V, area, terminals, render_V)
logdiag.register ("Ohmmeter", names_ohm, area, terminals, render_ohm) logdiag.register ("Ohmmeter", names_ohm, area, terminals, render_ohm)
logdiag.register ("Wattmeter", names_W, area, terminals, render_W)

View File

@ -1,50 +0,0 @@
-- Symbol names
local names_plus =
{
en = "Plus sign",
cs = "Znaménko plus",
sk = "Znamienko plus",
pl = "Znaczek plus",
de = "Pluszeichen"
}
local names_minus =
{
en = "Minus sign",
cs = "Znaménko mínus",
sk = "Znamienko mínus",
pl = "Znaczek minus",
de = "Minuszeichen"
}
-- Render area in base units (X1, Y1, X2, Y2)
local area = {-0.5, -0.5, 0.5, 0.5}
-- Terminal points
local terminals = {}
-- Rendering
local render_plus = function (cr)
-- The plus sign
cr:move_to (0, -0.4)
cr:line_to (0, 0.4)
cr:move_to (-0.4, 0)
cr:line_to (0.4, 0)
cr:stroke ()
end
local render_minus = function (cr)
-- The minus sign
cr:move_to (-0.4, 0)
cr:line_to (0.4, 0)
cr:stroke ()
end
-- Register the symbols
logdiag.register ("SignPlus", names_plus, area, terminals, render_plus)
logdiag.register ("SignMinus", names_minus, area, terminals, render_minus)

View File

@ -2,10 +2,7 @@
local names = local names =
{ {
en = "Switch", en = "Switch",
cs = "Spínač", cs = "Spínač"
sk = "Spínač",
pl = "Przełącznik",
de = "Schalter"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -17,16 +14,17 @@ local terminals = {{-2, 0}, {2, 0}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The switch contact -- The switch contact
cr:move_to (1.3, -1.3) cr.move_to (1.3, -1.3)
cr:line_to (-1, 0) cr.line_to (-1, 0)
-- The terminals -- The terminals
cr:line_to (-2, 0) cr.move_to (-2, 0)
cr.line_to (-1, 0)
cr:move_to (1, 0) cr.move_to (1, 0)
cr:line_to (2, 0) cr.line_to (2, 0)
cr:stroke () cr.stroke ()
end end
-- Register the symbol -- Register the symbol

View File

@ -2,10 +2,7 @@
local names = local names =
{ {
en = "Terminal", en = "Terminal",
cs = "Terminál", cs = "Terminál"
sk = "Terminál",
pl = "Terminał",
de = "Terminal"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -17,13 +14,13 @@ local terminals = {{-1, 0}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The circle -- The circle
cr:arc (0, 0, 0.3, 0, math.pi * 2) cr.arc (0, 0, 0.3, 0, math.pi * 2)
-- The contact -- The contact
cr:move_to (-1, 0) cr.move_to (-1, 0)
cr:line_to (-0.3, 0) cr.line_to (-0.3, 0)
cr:stroke () cr.stroke ()
end end
-- Register the symbol -- Register the symbol

View File

@ -2,62 +2,70 @@
local names_ac = local names_ac =
{ {
en = "AC voltage source", en = "AC voltage source",
cs = "Střídavý zdroj napětí", cs = "Střídavý zdroj napětí"
sk = "Striedavý zdroj napätia",
pl = "Źródło prądu zmiennego",
de = "Wechselstromquelle"
} }
local names_dc = local names_dc =
{ {
en = "DC voltage source", en = "DC voltage source",
cs = "Stejnosměrný zdroj napětí", cs = "Stejnosměrný zdroj napětí"
sk = "Stejnosmerný zdroj napätia",
pl = "Źródło prądu stałego",
de = "Gleichstromquelle"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
local area = {-2, -2, 2, 2} local area = {-3, -2, 3, 2}
-- Terminal points -- Terminal points
local terminals = {{-2, 0}, {2, 0}, {0, -2}, {0, 2}} local terminals = {{-3, 0}, {3, 0}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The circle -- The circle
cr:arc (0, 0, 2, 0, math.pi * 2) cr.arc (0, 0, 2, 0, math.pi * 2)
cr:stroke () -- The terminals
cr.move_to (-3, 0)
cr.line_to (-2, 0)
cr.move_to (2, 0)
cr.line_to (3, 0)
cr.stroke ()
end end
local render_ac = function (cr) local render_ac = function (cr)
render (cr) render (cr)
-- The AC symbol -- The AC symbol
cr:move_to (-1, 0.25) cr.move_to (-1, 0.25)
cr:curve_to (-0.4, -1.5, 0.4, 1.5, 1, -0.25) cr.curve_to (-0.4, -1.5, 0.4, 1.5, 1, -0.25)
cr:stroke () cr.stroke ()
end end
local render_dc = function (cr) local render_dc = function (cr)
render (cr) render (cr)
-- The DC symbol -- The DC symbol
cr:move_to (-1, -0.25) cr.move_to (-1, -0.25)
cr:line_to (1, -0.25) cr.line_to (1, -0.25)
cr:move_to (-1, 0.25) cr.move_to (-1, 0.25)
cr:line_to (-0.2, 0.25) cr.line_to (-0.2, 0.25)
cr:move_to (0.2, 0.25) cr.move_to (0.2, 0.25)
cr:line_to (1, 0.25) cr.line_to (1, 0.25)
cr:stroke () -- Polarity sign
cr.move_to (2.6, -0.6)
cr.line_to (2.6, -1.4)
cr.move_to (2.2, -1)
cr.line_to (3.0, -1)
cr.stroke ()
end end
-- Register the symbols -- Register the symbol
logdiag.register ("ACSource", names_ac, area, terminals, render_ac) logdiag.register ("ACSource", names_ac, area, terminals, render_ac)
logdiag.register ("DCSource", names_dc, area, terminals, render_dc) logdiag.register ("DCSource", names_dc, area, terminals, render_dc)

View File

@ -2,14 +2,18 @@
local names = local names =
{ {
en = "Capacitor", en = "Capacitor",
cs = "Kondenzátor", cs = "Kondenzátor"
sk = "Kondenzátor", }
pl = "Kondensator",
de = "Kondensator" local names_polar =
{
en = "Polarized capacitor",
cs = "Polarizovaný kondenzátor"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
local area = {-2, -1, 2, 1} local area = {-2, -1, 2, 1}
local area_polar = {-2, -1.5, 2, 1}
-- Terminal points -- Terminal points
local terminals = {{-2, 0}, {2, 0}} local terminals = {{-2, 0}, {2, 0}}
@ -17,23 +21,39 @@ local terminals = {{-2, 0}, {2, 0}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The vertical lines -- The vertical lines
cr:move_to (-0.2, -1) cr.move_to (-0.2, -1)
cr:line_to (-0.2, 1) cr.line_to (-0.2, 1)
cr:move_to (0.2, -1) cr.move_to (0.2, -1)
cr:line_to (0.2, 1) cr.line_to (0.2, 1)
-- The terminals -- The terminals
cr:move_to (-2, 0) cr.move_to (-2, 0)
cr:line_to (-0.2, 0) cr.line_to (-0.2, 0)
cr:move_to (0.2, 0) cr.move_to (0.2, 0)
cr:line_to (2, 0) cr.line_to (2, 0)
cr:stroke () cr.stroke ()
end
local render_polar = function (cr)
render (cr)
-- The plus sign
cr.move_to (-0.6, -1)
cr.line_to (-1.4, -1)
cr.move_to (-1, -1.4)
cr.line_to (-1, -0.6)
cr.stroke ()
end end
-- Register the symbol -- Register the symbol
logdiag.register ("Capacitor", names, area, terminals, render) logdiag.register ("Capacitor",
names, area, terminals, render)
logdiag.register ("CapacitorPolarized",
names_polar, area_polar, terminals, render_polar)

View File

@ -1,8 +1,5 @@
{ {
"en": "Passive", "en": "Passive",
"cs": "Pasivní", "cs": "Pasivní"
"sk": "Pasívne",
"pl": "Pasywne",
"de": "Passiv"
} }

View File

@ -2,37 +2,25 @@
local names = local names =
{ {
en = "Diode", en = "Diode",
cs = "Dioda", cs = "Dioda"
sk = "Dióda",
pl = "Dioda",
de = "Diode"
} }
local names_zener = local names_zener =
{ {
en = "Zener diode", en = "Zener diode",
cs = "Zenerova dioda", cs = "Zenerova dioda"
sk = "Zenerova dióda",
pl = "Dioda Zenera",
de = "Zenerdiode"
} }
local names_led = local names_led =
{ {
en = "Light-emitting diode", en = "Light-emitting diode",
cs = "Svítivá dioda", cs = "Svítivá dioda"
sk = "Svietivá dióda",
pl = "Dioda świecąca",
de = "Lichtemittierende Diode"
} }
local names_photo = local names_photo =
{ {
en = "Photodiode", en = "Photodiode",
cs = "Fotodioda", cs = "Fotodioda"
sk = "Fotodióda",
pl = "Fotodioda",
de = "Fotodiode"
} }
-- Render area in base units (X1, Y1, X2, Y2) -- Render area in base units (X1, Y1, X2, Y2)
@ -45,79 +33,79 @@ local terminals = {{-2, 0}, {2, 0}}
-- Rendering -- Rendering
local render = function (cr) local render = function (cr)
-- The triangle -- The triangle
cr:move_to (-1, -1) cr.move_to (-1, -1)
cr:line_to (1, 0) cr.line_to (1, 0)
cr:line_to (-1, 1) cr.line_to (-1, 1)
cr:close_path () cr.line_to (-1, -1)
-- The vertical line -- The vertical line
cr:move_to (1, 1) cr.move_to (1, 1)
cr:line_to (1, -1) cr.line_to (1, -1)
-- The terminals -- The terminals
cr:move_to (-2, 0) cr.move_to (-2, 0)
cr:line_to (2, 0) cr.line_to (2, 0)
cr:stroke () cr.stroke ()
end end
local render_zener = function (cr) local render_zener = function (cr)
render (cr) render (cr)
cr:move_to (1, 1) cr.move_to (1, 1)
cr:line_to (0.5, 1) cr.line_to (0.5, 1)
cr:stroke () cr.stroke ()
end end
local render_arrow = function (cr) local render_arrow = function (cr)
cr:move_to (0, 0) cr.move_to (0, 0)
cr:line_to (0, -1.5) cr.line_to (0, -1.5)
cr:stroke () cr.stroke ()
cr:move_to (-0.3, -0.7) cr.move_to (-0.3, -0.7)
cr:line_to (0, -1.5) cr.line_to (0, -1.5)
cr:line_to (0.3, -0.7) cr.line_to (0.3, -0.7)
cr:close_path () cr.close_path ()
cr:fill () cr.fill ()
end end
local render_radiation = function (cr) local render_radiation = function (cr)
cr:save () cr.save ()
cr:translate (-0.4, 0) cr.translate (-0.4, 0)
render_arrow (cr) render_arrow (cr)
cr:restore () cr.restore ()
cr:save () cr.save ()
cr:translate (0.4, 0) cr.translate (0.4, 0)
render_arrow (cr) render_arrow (cr)
cr:restore () cr.restore ()
end end
local render_led = function (cr) local render_led = function (cr)
render (cr) render (cr)
cr:save () cr.save ()
cr:translate (-0.3, -1.0) cr.translate (-0.3, -1.0)
cr:rotate (math.atan2 (1, 1)) cr.rotate (math.atan2 (1, 1))
render_radiation (cr) render_radiation (cr)
cr:restore () cr.restore ()
end end
local render_photo = function (cr) local render_photo = function (cr)
render (cr) render (cr)
cr:save () cr.save ()
cr:translate (0.75, -2.05) cr.translate (0.75, -2.05)
cr:rotate (math.atan2 (-1, -1)) cr.rotate (math.atan2 (-1, -1))
render_radiation (cr) render_radiation (cr)
cr:restore () cr.restore ()
end end
-- Register the symbol -- Register the symbol

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="128"
height="128"
id="svg2">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-924.36218)"
id="layer1">
<g
transform="translate(0,9.75)"
id="g3784">
<path
d="m 15,960.11218 25,0 0,0"
id="path2985"
style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 42,935.11218 0,50"
id="path2987"
style="fill:none;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 85,960.11218 -25,0 0,0"
id="path2985-2"
style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
d="m 58,935.11216 0,50.00002"
id="path2987-7"
style="fill:none;stroke:#000000;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
</g>
<path
d="m 29,1031.3622 15,0 c 0,0 0,-13 10,-13 10,0 10,15 10,15 0,0 0,-15 10,-15 10,0 10,15 10,15 0,0 0,-15 10,-15 10,0 10,13 10,13 l 15,0"
id="path3782"
style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

Some files were not shown because too many files have changed in this diff Show More