Compare commits
	
		
			225 Commits
		
	
	
		
			v0.1.0
			...
			b45670f9e9
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						b45670f9e9
	
				 | 
					
					
						|||
| 
						
						
							
						
						06e3c9e280
	
				 | 
					
					
						|||
| 
						
						
							
						
						073a4cd4a7
	
				 | 
					
					
						|||
| 
						
						
							
						
						f7807cada2
	
				 | 
					
					
						|||
| 
						
						
							
						
						08cf0ef2e6
	
				 | 
					
					
						|||
| 
						
						
							
						
						baf2dc8ccd
	
				 | 
					
					
						|||
| 
						
						
							
						
						a5e341bcc1
	
				 | 
					
					
						|||
| 
						
						
							
						
						bc8ceebef7
	
				 | 
					
					
						|||
| 
						
						
							
						
						da0a5c43dc
	
				 | 
					
					
						|||
| 
						
						
							
						
						384dad7bd8
	
				 | 
					
					
						|||
| 
						
						
							
						
						ada833a009
	
				 | 
					
					
						|||
| 
						
						
							
						
						924617e1ce
	
				 | 
					
					
						|||
| 
						
						
							
						
						67acddb26d
	
				 | 
					
					
						|||
| 
						
						
							
						
						bc1dd64fdf
	
				 | 
					
					
						|||
| 
						
						
							
						
						8c290df7b5
	
				 | 
					
					
						|||
| 
						
						
							
						
						5fc35517cb
	
				 | 
					
					
						|||
| 
						
						
							
						
						5a4cffd35e
	
				 | 
					
					
						|||
| 
						
						
							
						
						3a087ad581
	
				 | 
					
					
						|||
| 
						
						
							
						
						4305c603e9
	
				 | 
					
					
						|||
| 
						
						
							
						
						cbe23b7bb6
	
				 | 
					
					
						|||
| 
						
						
							
						
						2d103ed454
	
				 | 
					
					
						|||
| 
						
						
							
						
						885ccb46a3
	
				 | 
					
					
						|||
| 
						
						
							
						
						47fb9653b8
	
				 | 
					
					
						|||
| 
						
						
							
						
						42b6da1ffe
	
				 | 
					
					
						|||
| 
						
						
							
						
						98f16c2c76
	
				 | 
					
					
						|||
| 
						
						
							
						
						03c6ae0750
	
				 | 
					
					
						|||
| 
						
						
							
						
						95f53863ec
	
				 | 
					
					
						|||
| 
						
						
							
						
						8ac267c8db
	
				 | 
					
					
						|||
| 
						
						
							
						
						45dd1a4a86
	
				 | 
					
					
						|||
| 
						
						
							
						
						2c5fc3ebdd
	
				 | 
					
					
						|||
| 
						
						
							
						
						1ca42eb8e2
	
				 | 
					
					
						|||
| 
						
						
							
						
						8815d72db7
	
				 | 
					
					
						|||
| 
						
						
							
						
						3102bc0cb9
	
				 | 
					
					
						|||
| 
						
						
							
						
						7f357cb7c8
	
				 | 
					
					
						|||
| 
						
						
							
						
						b4db65d246
	
				 | 
					
					
						|||
| 
						
						
							
						
						af14119165
	
				 | 
					
					
						|||
| 
						
						
							
						
						cc47064379
	
				 | 
					
					
						|||
| 
						
						
							
						
						c0b2715c70
	
				 | 
					
					
						|||
| 
						
						
							
						
						1ef1add173
	
				 | 
					
					
						|||
| 
						
						
							
						
						41d68e6636
	
				 | 
					
					
						|||
| 
						
						
							
						
						12ac611a14
	
				 | 
					
					
						|||
| 
						
						
							
						
						033fe31b7b
	
				 | 
					
					
						|||
| 
						
						
							
						
						57e7252900
	
				 | 
					
					
						|||
| 
						
						
							
						
						45842016eb
	
				 | 
					
					
						|||
| 
						
						
							
						
						96fd6b6f24
	
				 | 
					
					
						|||
| 
						
						
							
						
						6c8a655bfc
	
				 | 
					
					
						|||
| 
						
						
							
						
						c2caf2b825
	
				 | 
					
					
						|||
| 
						
						
							
						
						f75c15fda5
	
				 | 
					
					
						|||
| 
						
						
							
						
						cc629fd160
	
				 | 
					
					
						|||
| 
						
						
							
						
						46821d2e49
	
				 | 
					
					
						|||
| 
						
						
							
						
						9aa9512190
	
				 | 
					
					
						|||
| 
						
						
							
						
						193b724709
	
				 | 
					
					
						|||
| 
						
						
							
						
						b5af31b048
	
				 | 
					
					
						|||
| 
						
						
							
						
						c09acf120c
	
				 | 
					
					
						|||
| 
						
						
							
						
						f9f1c830f8
	
				 | 
					
					
						|||
| 
						
						
							
						
						b353fc133e
	
				 | 
					
					
						|||
| 
						
						
							
						
						0c0b9640f8
	
				 | 
					
					
						|||
| 
						
						
							
						
						948a332d01
	
				 | 
					
					
						|||
| 
						
						
							
						
						ced3913e68
	
				 | 
					
					
						|||
| 
						
						
							
						
						97f551d918
	
				 | 
					
					
						|||
| 2a4572294b | |||
| 64f5a7abbc | |||
| b552b3cae9 | |||
| 7a3ceb5435 | |||
| 24731d6831 | |||
| e74d582eca | |||
| 4e0e09a62b | |||
| c117a6ddaa | |||
| d55422e0a5 | |||
| 9e54e5a49c | |||
| f2ae2fbd35 | |||
| af51c00c93 | |||
| de133622a2 | |||
| 61f7536e22 | |||
| b62b7bfa18 | |||
| 260a15fdda | |||
| 4fc23df6bd | |||
| 4d0721bf68 | |||
| 5bb6a05e1c | |||
| 733fb54580 | |||
| ec29804080 | |||
| cd3599bd1b | |||
| 1adeac6c22 | |||
| 13f212d4e9 | |||
| a7f869b707 | |||
| fb6f89fb5c | |||
| e1225accf4 | |||
| 5b16953a2f | |||
| adead30747 | |||
| 616650c558 | |||
| 5c17944454 | |||
| c41f3ae529 | |||
| 7617e6a002 | |||
| c95519830d | |||
| 6e6cf05093 | |||
| 36ffb0f8cf | |||
| 64a97f54bf | |||
| 4f8b17e67a | |||
| 48d353a5cb | |||
| 313a47843f | |||
| f0ac99072e | |||
| c535bd2383 | |||
| fa602c20ec | |||
| 0066917014 | |||
| f21395779a | |||
| 366cfa3473 | |||
| da3e53215b | |||
| 295c18ae47 | |||
| b19326a1e0 | |||
| 733dfef8e0 | |||
| 16d45a485f | |||
| 492daa3ce3 | |||
| 24b4e9956b | |||
| 66aca31467 | |||
| 3b85eeec8d | |||
| c12c6fbf56 | |||
| 09d6bda3db | |||
| 15d8c257d1 | |||
| ec4f78c008 | |||
| 819917536e | |||
| 8acfeae8c8 | |||
| 47023938ca | |||
| 3290aa877d | |||
| 77aad430ef | |||
| 2156a92a09 | |||
| 9569d96cd6 | |||
| 6a633c8321 | |||
| 0e952b084c | |||
| ef64c0427f | |||
| a915bf4496 | |||
| 00a50737f3 | |||
| a18b6d6f35 | |||
| 6a24ede141 | |||
| 6c925b7092 | |||
| 4196a10ece | |||
| cf5260990c | |||
| 20c2595f2d | |||
| 89ec69b067 | |||
| d9ce2716ed | |||
| a1b79a55d2 | |||
| 9366c42026 | |||
| bb224bafd0 | |||
| f55afb6542 | |||
| b0ecd81212 | |||
| 94f27cb38c | |||
| b3ccabe627 | |||
| d9a310a691 | |||
| 745bbf0ce5 | |||
| 72b562760e | |||
| 2e1adc3d56 | |||
| ae8d44a75b | |||
| 50b0d3c395 | |||
| 4e440eb35b | |||
| b2223d6595 | |||
| e1e9a6d319 | |||
| 2509f0af52 | |||
| 5d1c8bbf75 | |||
| a2b898b610 | |||
| c36ca83406 | |||
| d8fd4430fc | |||
| 82bf779405 | |||
| cd66c3d84a | |||
| 8001619bf1 | |||
| 423afa8eec | |||
| ef2966e9bc | |||
| 7069108a0a | |||
| d4cff849f8 | |||
| 3430bf30bb | |||
| 0640067bf0 | |||
| 1c118251bd | |||
| 94cb6ee53a | |||
| c8caca073f | |||
| 6ae08ee425 | |||
| 89b20380d3 | |||
| e40591feb8 | |||
| 01dea6fb2e | |||
| f821e029d7 | |||
| df5f14060b | |||
| 582b24562c | |||
| bd1b3adf56 | |||
| 8cdefbca29 | |||
| 0aaa214a75 | |||
| b37f856557 | |||
| 7d2b3a8c2f | |||
| 95b92e12f9 | |||
| 403a9d702a | |||
| f9827e2ff3 | |||
| d4bfd8a504 | |||
| 8f8866ffc4 | |||
| f074bc6742 | |||
| 8aef3fc772 | |||
| b5ff3b5bbb | |||
| 58e3e43c15 | |||
| fdb6418733 | |||
| 6820d27efa | |||
| 781273c236 | |||
| 7fa6efbaec | |||
| 6a8238846c | |||
| 412a01690b | |||
| 841e9e9f85 | |||
| ac56c16ab8 | |||
| baed5ee4bd | |||
| 5ccabad6ce | |||
| 1730064ed3 | |||
| 8ac4674a8e | |||
| 0841e75076 | |||
| bc491d0d0f | |||
| cffc6f01a5 | |||
| ebd4cd3a17 | |||
| 69f3ce89c5 | |||
| 5fd66ada46 | |||
| 440a9da5fc | |||
| ee8a82925f | |||
| 66dc2948df | |||
| 948e9d53d2 | |||
| 9a217e97c8 | |||
| 68e6e4a7e8 | |||
| b7875c361f | |||
| 299ce010bd | |||
| 2c5f2f5b3f | |||
| d96acedcdb | |||
| 39fb4bb56f | |||
| ab3e2733ce | |||
| 93bac99a10 | |||
| da34bbb3bb | 
							
								
								
									
										37
									
								
								.clang-format
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,37 @@
 | 
			
		||||
# 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
 | 
			
		||||
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"
 | 
			
		||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						@@ -1,3 +1,4 @@
 | 
			
		||||
/build
 | 
			
		||||
/win32-depends
 | 
			
		||||
/liblogdiag/ld-marshal.[ch]
 | 
			
		||||
/CMakeLists.txt.user
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,3 @@
 | 
			
		||||
[submodule "vera++"]
 | 
			
		||||
	path = vera++
 | 
			
		||||
	url = https://bitbucket.org/verateam/vera.git
 | 
			
		||||
							
								
								
									
										365
									
								
								CMakeLists.txt
									
									
									
									
									
								
							
							
						
						@@ -1,56 +1,38 @@
 | 
			
		||||
project (logdiag C)
 | 
			
		||||
cmake_minimum_required (VERSION 2.6.2)
 | 
			
		||||
 | 
			
		||||
# Default to 2.6.3 behaviour
 | 
			
		||||
cmake_policy (VERSION 2.6.3)
 | 
			
		||||
# The last version with Windows XP support is 3.13, we want to keep that
 | 
			
		||||
cmake_minimum_required (VERSION 3.10)
 | 
			
		||||
project (logdiag VERSION 0.2.1 LANGUAGES C)
 | 
			
		||||
 | 
			
		||||
# Options
 | 
			
		||||
option (OPTION_NOINSTALL "Only for developers; work without installing" OFF)
 | 
			
		||||
 | 
			
		||||
if (OPTION_NOINSTALL)
 | 
			
		||||
	set (OPTION_NOINSTALL 1)
 | 
			
		||||
else (OPTION_NOINSTALL)
 | 
			
		||||
	set (OPTION_NOINSTALL 0)
 | 
			
		||||
endif (OPTION_NOINSTALL)
 | 
			
		||||
option (OPTION_USE_VERA "Use vera++ for source code style checks" OFF)
 | 
			
		||||
option (OPTION_NOINSTALL "For developers only--work without installing" OFF)
 | 
			
		||||
option (OPTION_GTKDOC "For developers only--enable use of gtk-doc" OFF)
 | 
			
		||||
option (BUILD_TESTING "Build tests" OFF)
 | 
			
		||||
 | 
			
		||||
# Project information
 | 
			
		||||
set (project_VERSION_MAJOR "0")
 | 
			
		||||
set (project_VERSION_MINOR "1")
 | 
			
		||||
set (project_VERSION_PATCH "0")
 | 
			
		||||
 | 
			
		||||
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")
 | 
			
		||||
set (project_URL "https://git.janouch.name/p/logdiag")
 | 
			
		||||
 | 
			
		||||
# For custom modules
 | 
			
		||||
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)
 | 
			
		||||
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
 | 
			
		||||
 | 
			
		||||
# Automatic retrieval of dependencies
 | 
			
		||||
if (WIN32)
 | 
			
		||||
	set (WIN32_DEPENDS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/win32-depends)
 | 
			
		||||
	set (WIN32_DEPENDS_PATH ${PROJECT_SOURCE_DIR}/win32-depends)
 | 
			
		||||
	list (APPEND CMAKE_PREFIX_PATH ${WIN32_DEPENDS_PATH})
 | 
			
		||||
	list (APPEND CMAKE_INCLUDE_PATH ${WIN32_DEPENDS_PATH}/lib)
 | 
			
		||||
	list (APPEND CMAKE_C_FLAGS "-mms-bitfields")
 | 
			
		||||
	set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mms-bitfields")
 | 
			
		||||
 | 
			
		||||
	if (CMAKE_CROSSCOMPILING)
 | 
			
		||||
		list (APPEND CMAKE_FIND_ROOT_PATH ${WIN32_DEPENDS_PATH})
 | 
			
		||||
	endif (CMAKE_CROSSCOMPILING)
 | 
			
		||||
 | 
			
		||||
	set (PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE)
 | 
			
		||||
	# Seems like there is a regression setting this to two paths in one,
 | 
			
		||||
	# setting the path manually
 | 
			
		||||
	set (ENV{PKG_CONFIG_PATH} "${WIN32_DEPENDS_PATH}/lib/pkgconfig")
 | 
			
		||||
 | 
			
		||||
	add_custom_target (win32-depends COMMAND ${CMAKE_COMMAND} -P
 | 
			
		||||
		${CMAKE_CURRENT_SOURCE_DIR}/Win32Depends.cmake
 | 
			
		||||
		WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
 | 
			
		||||
		${PROJECT_SOURCE_DIR}/Win32Depends.cmake
 | 
			
		||||
		WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
 | 
			
		||||
	add_custom_target (win32-depends-clean COMMAND ${CMAKE_COMMAND} -E
 | 
			
		||||
		remove_directory ${WIN32_DEPENDS_PATH})
 | 
			
		||||
endif (WIN32)
 | 
			
		||||
@@ -60,7 +42,7 @@ find_program (CONVERT_EXECUTABLE convert)
 | 
			
		||||
mark_as_advanced (CONVERT_EXECUTABLE)
 | 
			
		||||
 | 
			
		||||
if (CONVERT_EXECUTABLE AND NOT WIN32)
 | 
			
		||||
	set (icon_base ${CMAKE_CURRENT_SOURCE_DIR}/share/icons/hicolor)
 | 
			
		||||
	set (icon_base ${PROJECT_SOURCE_DIR}/share/icons/hicolor)
 | 
			
		||||
	set (icon_svg ${icon_base}/scalable/apps/logdiag.svg)
 | 
			
		||||
	set (icon_size_list 16x16 32x32 48x48)
 | 
			
		||||
 | 
			
		||||
@@ -70,7 +52,7 @@ if (CONVERT_EXECUTABLE AND NOT WIN32)
 | 
			
		||||
		set (icon_png_path ${icon_base}/${icon_size}/apps)
 | 
			
		||||
		set (icon_png ${icon_png_path}/logdiag.png)
 | 
			
		||||
		list (APPEND icon_png_list ${icon_png})
 | 
			
		||||
		set (icon_symbolic logdiag_icons_${icon_size})
 | 
			
		||||
		set (icon_symbolic ${PROJECT_NAME}_icons_${icon_size})
 | 
			
		||||
		list (APPEND icon_symbolic_list ${icon_symbolic})
 | 
			
		||||
 | 
			
		||||
		add_custom_command (OUTPUT ${icon_symbolic}
 | 
			
		||||
@@ -82,31 +64,45 @@ if (CONVERT_EXECUTABLE AND NOT WIN32)
 | 
			
		||||
			PROPERTIES SYMBOLIC TRUE)
 | 
			
		||||
	endforeach (icon_size)
 | 
			
		||||
 | 
			
		||||
	set (icon_ico ${CMAKE_CURRENT_SOURCE_DIR}/share/logdiag.ico)
 | 
			
		||||
	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}
 | 
			
		||||
		COMMENT "Generating logdiag.ico" VERBATIM)
 | 
			
		||||
endif (CONVERT_EXECUTABLE AND NOT WIN32)
 | 
			
		||||
 | 
			
		||||
# Dependencies
 | 
			
		||||
find_package (GTK2 2.12 REQUIRED gtk)
 | 
			
		||||
find_package (Lua51 REQUIRED)
 | 
			
		||||
find_package (JsonGlib REQUIRED)
 | 
			
		||||
find_package (PkgConfig REQUIRED)
 | 
			
		||||
pkg_check_modules (GTK3 REQUIRED gtk+-3.0 json-glib-1.0)
 | 
			
		||||
 | 
			
		||||
if (NOT WIN32)
 | 
			
		||||
	pkg_search_module (Lua REQUIRED lua>=5.2 lua5.3 lua-5.3 lua5.2 lua-5.2)
 | 
			
		||||
else (NOT WIN32)
 | 
			
		||||
	# 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 (LUA_VERSION_STRING VERSION_LESS "5.2")
 | 
			
		||||
	set (Lua_LIBRARIES ${LUA_LIBRARIES})
 | 
			
		||||
	set (Lua_INCLUDE_DIRS ${LUA_INCLUDE_DIR})
 | 
			
		||||
endif (NOT WIN32)
 | 
			
		||||
 | 
			
		||||
# This actually fucks up MinGW cross-compilation if omitted
 | 
			
		||||
link_directories (${GTK3_LIBRARY_DIRS})
 | 
			
		||||
 | 
			
		||||
# Localization
 | 
			
		||||
find_package (Gettext)
 | 
			
		||||
if (GETTEXT_FOUND)
 | 
			
		||||
	set (HAVE_GETTEXT true)
 | 
			
		||||
	file (GLOB project_TRANSLATIONS ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po)
 | 
			
		||||
	GETTEXT_CREATE_TRANSLATIONS (
 | 
			
		||||
		${CMAKE_CURRENT_SOURCE_DIR}/po/${CMAKE_PROJECT_NAME}.pot
 | 
			
		||||
		ALL ${project_TRANSLATIONS})
 | 
			
		||||
endif (GETTEXT_FOUND)
 | 
			
		||||
find_package (Gettext REQUIRED)
 | 
			
		||||
file (GLOB project_PO_FILES ${PROJECT_SOURCE_DIR}/po/*.po)
 | 
			
		||||
GETTEXT_CREATE_TRANSLATIONS (
 | 
			
		||||
	${PROJECT_SOURCE_DIR}/po/${PROJECT_NAME}.pot
 | 
			
		||||
	ALL ${project_PO_FILES})
 | 
			
		||||
 | 
			
		||||
# Documentation
 | 
			
		||||
# TODO: Add pregenerated docs to the tree
 | 
			
		||||
find_package (GtkDoc)
 | 
			
		||||
set (project_DOC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/docs/reference")
 | 
			
		||||
foreach (file ${project_PO_FILES})
 | 
			
		||||
	get_filename_component (translation "${file}" NAME_WE)
 | 
			
		||||
	list (APPEND project_TRANSLATIONS "${translation}")
 | 
			
		||||
endforeach (file)
 | 
			
		||||
 | 
			
		||||
# Project source files
 | 
			
		||||
set (liblogdiag_SOURCES
 | 
			
		||||
@@ -117,15 +113,17 @@ set (liblogdiag_SOURCES
 | 
			
		||||
	liblogdiag/ld-diagram-object.c
 | 
			
		||||
	liblogdiag/ld-diagram-symbol.c
 | 
			
		||||
	liblogdiag/ld-diagram-connection.c
 | 
			
		||||
	liblogdiag/ld-canvas.c
 | 
			
		||||
	liblogdiag/ld-diagram-view.c
 | 
			
		||||
	liblogdiag/ld-library.c
 | 
			
		||||
	liblogdiag/ld-library-toolbar.c
 | 
			
		||||
	liblogdiag/ld-symbol-category.c
 | 
			
		||||
	liblogdiag/ld-category-view.c
 | 
			
		||||
	liblogdiag/ld-category-tree-view.c
 | 
			
		||||
	liblogdiag/ld-category-symbol-view.c
 | 
			
		||||
	liblogdiag/ld-category.c
 | 
			
		||||
	liblogdiag/ld-symbol.c
 | 
			
		||||
	liblogdiag/ld-lua.c
 | 
			
		||||
	liblogdiag/ld-lua-symbol.c)
 | 
			
		||||
set (liblogdiag_HEADERS
 | 
			
		||||
	${CMAKE_CURRENT_BINARY_DIR}/config.h
 | 
			
		||||
	${PROJECT_BINARY_DIR}/config.h
 | 
			
		||||
	liblogdiag/liblogdiag.h
 | 
			
		||||
	liblogdiag/ld-marshal.h
 | 
			
		||||
	liblogdiag/ld-types.h
 | 
			
		||||
@@ -134,10 +132,12 @@ set (liblogdiag_HEADERS
 | 
			
		||||
	liblogdiag/ld-diagram-object.h
 | 
			
		||||
	liblogdiag/ld-diagram-symbol.h
 | 
			
		||||
	liblogdiag/ld-diagram-connection.h
 | 
			
		||||
	liblogdiag/ld-canvas.h
 | 
			
		||||
	liblogdiag/ld-diagram-view.h
 | 
			
		||||
	liblogdiag/ld-library.h
 | 
			
		||||
	liblogdiag/ld-library-toolbar.h
 | 
			
		||||
	liblogdiag/ld-symbol-category.h
 | 
			
		||||
	liblogdiag/ld-category-view.h
 | 
			
		||||
	liblogdiag/ld-category-tree-view.h
 | 
			
		||||
	liblogdiag/ld-category-symbol-view.h
 | 
			
		||||
	liblogdiag/ld-category.h
 | 
			
		||||
	liblogdiag/ld-symbol.h
 | 
			
		||||
	liblogdiag/ld-lua.h
 | 
			
		||||
	liblogdiag/ld-lua-private.h
 | 
			
		||||
@@ -171,9 +171,11 @@ if (WIN32)
 | 
			
		||||
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})
 | 
			
		||||
add_definitions (-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36)
 | 
			
		||||
add_definitions (-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36)
 | 
			
		||||
configure_file (${PROJECT_SOURCE_DIR}/config.h.in
 | 
			
		||||
	${PROJECT_BINARY_DIR}/config.h)
 | 
			
		||||
include_directories (${PROJECT_BINARY_DIR})
 | 
			
		||||
 | 
			
		||||
# Generate marshallers
 | 
			
		||||
find_program (GLIB_GENMARSHAL_EXECUTABLE glib-genmarshal)
 | 
			
		||||
@@ -209,14 +211,17 @@ function (glib_genmarshal base prefix)
 | 
			
		||||
		COMMENT "Generating marshallers header file")
 | 
			
		||||
endfunction (glib_genmarshal)
 | 
			
		||||
 | 
			
		||||
glib_genmarshal (${CMAKE_CURRENT_SOURCE_DIR}/liblogdiag/ld-marshal
 | 
			
		||||
glib_genmarshal (${PROJECT_SOURCE_DIR}/liblogdiag/ld-marshal
 | 
			
		||||
	ld_marshal)
 | 
			
		||||
 | 
			
		||||
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
 | 
			
		||||
include_directories (${GTK2_INCLUDE_DIRS}
 | 
			
		||||
	${JSON_GLIB_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
 | 
			
		||||
set (logdiag_LIBS ${GTK2_LIBRARIES}
 | 
			
		||||
	${JSON_GLIB_LIBRARIES} ${LUA_LIBRARIES})
 | 
			
		||||
include_directories (${PROJECT_SOURCE_DIR})
 | 
			
		||||
include_directories (${GTK3_INCLUDE_DIRS} ${Lua_INCLUDE_DIRS})
 | 
			
		||||
set (logdiag_LIBS ${GTK3_LIBRARIES} ${Lua_LIBRARIES} m)
 | 
			
		||||
 | 
			
		||||
if (WIN32)
 | 
			
		||||
	find_package (LibIntl REQUIRED)
 | 
			
		||||
	list (APPEND logdiag_LIBS ${LIBINTL_LIBRARIES} shell32)
 | 
			
		||||
endif (WIN32)
 | 
			
		||||
 | 
			
		||||
# Build the library
 | 
			
		||||
add_library (liblogdiag STATIC ${liblogdiag_SOURCES} ${liblogdiag_HEADERS})
 | 
			
		||||
@@ -227,50 +232,152 @@ add_executable (logdiag WIN32 ${logdiag_SOURCES} ${logdiag_HEADERS})
 | 
			
		||||
target_link_libraries (logdiag liblogdiag ${logdiag_LIBS})
 | 
			
		||||
 | 
			
		||||
# Testing
 | 
			
		||||
option (BUILD_TESTING "Build tests" OFF)
 | 
			
		||||
 | 
			
		||||
if (BUILD_TESTING)
 | 
			
		||||
	enable_testing ()
 | 
			
		||||
 | 
			
		||||
	foreach (name ${logdiag_TESTS})
 | 
			
		||||
		add_executable (test-${name} tests/${name}.c)
 | 
			
		||||
		target_link_libraries (test-${name} liblogdiag ${logdiag_LIBS})
 | 
			
		||||
 | 
			
		||||
		add_test (test-${name} test-${name})
 | 
			
		||||
		add_test (NAME test-${name} COMMAND test-${name})
 | 
			
		||||
		list (APPEND logdiag_TEST_TARGETS test-${name})
 | 
			
		||||
	endforeach (name)
 | 
			
		||||
	if (WIN32 AND NOT CMAKE_CROSSCOMPILING)
 | 
			
		||||
		set_tests_properties (${logdiag_TEST_TARGETS}
 | 
			
		||||
			PROPERTIES ENVIRONMENT "PATH=${WIN32_DEPENDS_PATH}/bin")
 | 
			
		||||
	endif ()
 | 
			
		||||
endif (BUILD_TESTING)
 | 
			
		||||
 | 
			
		||||
# Generate documentation
 | 
			
		||||
if (GTK_DOC_FOUND)
 | 
			
		||||
	GTK_DOC_RUN (WORKING_DIR ${project_DOC_DIR}
 | 
			
		||||
		SOURCE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/liblogdiag
 | 
			
		||||
		SCANGOBJ liblogdiag ${logdiag_LIBS}
 | 
			
		||||
		XML ${project_DOC_DIR}/xml --sgml-mode
 | 
			
		||||
		HTML ${project_DOC_DIR}/html)
 | 
			
		||||
endif (GTK_DOC_FOUND)
 | 
			
		||||
if (OPTION_GTKDOC)
 | 
			
		||||
	find_package (GtkDoc 1.25 REQUIRED)
 | 
			
		||||
	set (project_DOC_DIR "${PROJECT_BINARY_DIR}/liblogdiag")
 | 
			
		||||
 | 
			
		||||
	# Extracted LDFLAGS didn't contain -l in CMake 3.21.3 and gtk-doc 1.33.2,
 | 
			
		||||
	# pass them explicitly and work around insanity; CMake still exits with
 | 
			
		||||
	# an error and gtk-doc produces empty HTML documentation
 | 
			
		||||
	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})
 | 
			
		||||
 | 
			
		||||
if (OPTION_USE_VERA)
 | 
			
		||||
	# Force this off, we don't need it
 | 
			
		||||
	option (VERA_LUA "" OFF)
 | 
			
		||||
 | 
			
		||||
	# Make it build within the same build tree
 | 
			
		||||
	get_directory_property (backup_includes INCLUDE_DIRECTORIES)
 | 
			
		||||
	set_directory_properties (PROPERTIES INCLUDE_DIRECTORIES "")
 | 
			
		||||
	set (backup_source_dir "${CMAKE_SOURCE_DIR}")
 | 
			
		||||
	set (CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/vera++")
 | 
			
		||||
 | 
			
		||||
	add_subdirectory ("vera++")
 | 
			
		||||
 | 
			
		||||
	set_directory_properties (PROPERTIES INCLUDE_DIRECTORIES "${backup_includes}")
 | 
			
		||||
	set (CMAKE_SOURCE_DIR "${backup_source_dir}")
 | 
			
		||||
 | 
			
		||||
	# Check the sources
 | 
			
		||||
	# XXX: maybe do it per source file and not all at once
 | 
			
		||||
	set (vera_srcs ${liblogdiag_SOURCES} ${logdiag_SOURCES} ${logdiag_HEADERS})
 | 
			
		||||
	set (vera_output ${PROJECT_BINARY_DIR}/vera.log)
 | 
			
		||||
	add_custom_command (OUTPUT ${vera_output}
 | 
			
		||||
		COMMAND vera
 | 
			
		||||
			-R F001 -R L001 -R T001 -R T004 -R T005 -R T006
 | 
			
		||||
			-R T007 -R T009 -R T010 -R T015 -R T017 -R T018
 | 
			
		||||
			-R L004 -P max-line-length=80
 | 
			
		||||
			-R L005 -P max-consecutive-empty-lines=2
 | 
			
		||||
			--root ${CMAKE_SOURCE_DIR}/vera++
 | 
			
		||||
			--std-report=-
 | 
			
		||||
			--std-report=${vera_output}
 | 
			
		||||
			--warning -s
 | 
			
		||||
			${vera_srcs}
 | 
			
		||||
		DEPENDS ${vera_srcs}
 | 
			
		||||
		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
 | 
			
		||||
		COMMENT "Checking style for logdiag")
 | 
			
		||||
 | 
			
		||||
	add_custom_target (logdiag_vera ALL DEPENDS ${vera_output})
 | 
			
		||||
endif (OPTION_USE_VERA)
 | 
			
		||||
 | 
			
		||||
# 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 (NOT GLIB_COMPILE_SCHEMAS_EXECUTABLE)
 | 
			
		||||
 | 
			
		||||
set (GSETTINGS_DIR "${PROJECT_SOURCE_DIR}/share")
 | 
			
		||||
set (GSETTINGS_SCHEMAS "${GSETTINGS_DIR}/org.logdiag.gschema.xml")
 | 
			
		||||
 | 
			
		||||
add_custom_target (${PROJECT_NAME}_gschema_check
 | 
			
		||||
	COMMAND ${GLIB_COMPILE_SCHEMAS_EXECUTABLE} --dry-run "${GSETTINGS_DIR}"
 | 
			
		||||
	DEPENDS "${GSETTINGS_SCHEMAS}"
 | 
			
		||||
	COMMENT "Checking GSettings schema files" VERBATIM)
 | 
			
		||||
 | 
			
		||||
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 (OPTION_NOINSTALL)
 | 
			
		||||
 | 
			
		||||
# Installation
 | 
			
		||||
install (DIRECTORY share/gui share/library
 | 
			
		||||
	DESTINATION share/${CMAKE_PROJECT_NAME})
 | 
			
		||||
 | 
			
		||||
if (WIN32)
 | 
			
		||||
	install (TARGETS logdiag DESTINATION .)
 | 
			
		||||
	install (DIRECTORY
 | 
			
		||||
		${WIN32_DEPENDS_PATH}/bin/
 | 
			
		||||
		DESTINATION .
 | 
			
		||||
		FILES_MATCHING PATTERN "*.dll")
 | 
			
		||||
		FILES_MATCHING PATTERN "*.dll" PATTERN "gspawn-*-helper.exe")
 | 
			
		||||
	install (DIRECTORY
 | 
			
		||||
		${WIN32_DEPENDS_PATH}/etc/
 | 
			
		||||
		DESTINATION etc)
 | 
			
		||||
	install (DIRECTORY
 | 
			
		||||
		${WIN32_DEPENDS_PATH}/lib/glib-2.0
 | 
			
		||||
		${WIN32_DEPENDS_PATH}/lib/gtk-2.0
 | 
			
		||||
		${WIN32_DEPENDS_PATH}/lib/gdk-pixbuf-2.0
 | 
			
		||||
		DESTINATION lib)
 | 
			
		||||
		DESTINATION lib
 | 
			
		||||
		FILES_MATCHING PATTERN "*" PATTERN "*.a" EXCLUDE)
 | 
			
		||||
	install (DIRECTORY
 | 
			
		||||
		${WIN32_DEPENDS_PATH}/share/locale
 | 
			
		||||
		${WIN32_DEPENDS_PATH}/share/themes
 | 
			
		||||
		DESTINATION share)
 | 
			
		||||
		${WIN32_DEPENDS_PATH}/share/glib-2.0/schemas
 | 
			
		||||
		DESTINATION share/glib-2.0
 | 
			
		||||
		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
 | 
			
		||||
	file (GLOB locales ${WIN32_DEPENDS_PATH}/share/locale/*)
 | 
			
		||||
	foreach (locale ${locales})
 | 
			
		||||
		get_filename_component (translation ${locale} NAME)
 | 
			
		||||
		list (FIND project_TRANSLATIONS ${translation} translation_found)
 | 
			
		||||
		if (translation_found GREATER -1)
 | 
			
		||||
			install (DIRECTORY
 | 
			
		||||
				${WIN32_DEPENDS_PATH}/share/locale/${translation}
 | 
			
		||||
				DESTINATION share/locale)
 | 
			
		||||
		endif (translation_found GREATER -1)
 | 
			
		||||
	endforeach (locale)
 | 
			
		||||
 | 
			
		||||
	install (SCRIPT Win32Cleanup.cmake)
 | 
			
		||||
else (WIN32)
 | 
			
		||||
	install (TARGETS logdiag DESTINATION bin)
 | 
			
		||||
	install (FILES share/logdiag.desktop DESTINATION share/applications)
 | 
			
		||||
@@ -278,51 +385,73 @@ else (WIN32)
 | 
			
		||||
	install (DIRECTORY share/icons DESTINATION share)
 | 
			
		||||
# Don't install the documentation yet as we don't install any library
 | 
			
		||||
#	install (DIRECTORY "${project_DOC_DIR}/html/"
 | 
			
		||||
#		DESTINATION share/gtk-doc/html/${CMAKE_PROJECT_NAME})
 | 
			
		||||
	install (FILES LICENSE DESTINATION share/doc/${CMAKE_PROJECT_NAME})
 | 
			
		||||
#		DESTINATION share/gtk-doc/html/${PROJECT_NAME})
 | 
			
		||||
	install (FILES LICENSE NEWS DESTINATION share/doc/${PROJECT_NAME})
 | 
			
		||||
endif (WIN32)
 | 
			
		||||
 | 
			
		||||
install (DIRECTORY docs/user-guide DESTINATION share/doc/${PROJECT_NAME})
 | 
			
		||||
install (DIRECTORY share/gui share/library DESTINATION share/${PROJECT_NAME})
 | 
			
		||||
install (FILES ${GSETTINGS_SCHEMAS} DESTINATION share/glib-2.0/schemas)
 | 
			
		||||
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
 | 
			
		||||
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Schematic editor")
 | 
			
		||||
set (CPACK_PACKAGE_VENDOR "Přemysl Janouch")
 | 
			
		||||
set (CPACK_PACKAGE_CONTACT "p.janouch@gmail.com")
 | 
			
		||||
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})
 | 
			
		||||
set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch")
 | 
			
		||||
set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>")
 | 
			
		||||
set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
 | 
			
		||||
set (CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
 | 
			
		||||
 | 
			
		||||
if (WIN32)
 | 
			
		||||
	set (CPACK_GENERATOR "NSIS;ZIP")
 | 
			
		||||
else (WIN32)
 | 
			
		||||
	set (CPACK_GENERATOR "TGZ;ZIP")
 | 
			
		||||
	set (CPACK_SET_DESTDIR TRUE)
 | 
			
		||||
endif (WIN32)
 | 
			
		||||
 | 
			
		||||
set (CPACK_PACKAGE_FILE_NAME
 | 
			
		||||
	"${CMAKE_PROJECT_NAME}-${project_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
 | 
			
		||||
set (CPACK_PACKAGE_INSTALL_DIRECTORY
 | 
			
		||||
	"${CMAKE_PROJECT_NAME} ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
 | 
			
		||||
	"${PROJECT_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
 | 
			
		||||
set (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME} ${CPACK_PACKAGE_VERSION}")
 | 
			
		||||
 | 
			
		||||
# XXX: It is still possible to install multiple copies, making commands collide.
 | 
			
		||||
set (CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
 | 
			
		||||
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_CREATE_ICONS_EXTRA
 | 
			
		||||
	"CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\logdiag.lnk' '\$INSTDIR\\\\logdiag.exe'")
 | 
			
		||||
set (CPACK_NSIS_DELETE_ICONS_EXTRA
 | 
			
		||||
	"Delete '\$SMPROGRAMS\\\\$MUI_TEMP\\\\logdiag.lnk'")
 | 
			
		||||
set (CPACK_NSIS_URL_INFO_ABOUT "${project_URL}")
 | 
			
		||||
set (CPACK_NSIS_HELP_LINK "${project_URL}")
 | 
			
		||||
# Or CPACK_NSIS_EXECUTABLES_DIRECTORY needs to be changed from "bin"
 | 
			
		||||
set (CPACK_NSIS_MENU_LINKS "logdiag.exe" ${PROJECT_NAME})
 | 
			
		||||
set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS [[
 | 
			
		||||
	WriteRegStr HKCR '.ldd' '' 'logdiag.Diagram'
 | 
			
		||||
	WriteRegStr HKCR 'logdiag.Diagram' '' 'logdiag Diagram'
 | 
			
		||||
	WriteRegStr HKCR 'logdiag.Diagram\\shell\\open\\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)'
 | 
			
		||||
]])
 | 
			
		||||
set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS [[
 | 
			
		||||
	DeleteRegKey HKCR 'logdiag.Diagram'
 | 
			
		||||
	System::Call 'shell32::SHChangeNotify(i,i,i,i) (0x08000000, 0x1000, 0, 0)'
 | 
			
		||||
]])
 | 
			
		||||
 | 
			
		||||
set (CPACK_DEBIAN_PACKAGE_DEPENDS
 | 
			
		||||
	"libgtk2.0-0 (>= 2.12), libjson-glib-1.0-0 (>= 0.10.4), liblua5.1-0, librsvg2-common")
 | 
			
		||||
	"libgtk3.0-0 (>= 3.8), libjson-glib-1.0-0 (>= 0.10.4), liblua5.2-0")
 | 
			
		||||
set (CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS
 | 
			
		||||
	"libgtk2.0-dev (>= 2.12), libjson-glib-dev (>= 0.10.4), liblua5.1-0-dev")
 | 
			
		||||
	"libgtk3.0-dev (>= 3.8), libjson-glib-dev (>= 0.10.4), liblua5.2-0-dev")
 | 
			
		||||
set (CPACK_DEBIAN_PACKAGE_SECTION "Electronics")
 | 
			
		||||
set (CPACK_DEBIAN_PACKAGE_HOMEPAGE "${project_URL}")
 | 
			
		||||
 | 
			
		||||
set (CPACK_RPM_PACKAGE_REQUIRES "gtk2 >= 2.12, json-glib >= 0.10.4, lua = 5.1, librsvg2")
 | 
			
		||||
set (CPACK_RPM_PACKAGE_REQUIRES "gtk3 >= 3.8, json-glib >= 0.10.4, lua = 5.2")
 | 
			
		||||
set (CPACK_RPM_PACKAGE_GROUP "Graphics")
 | 
			
		||||
set (CPACK_RPM_PACKAGE_LICENSE "BSD")
 | 
			
		||||
set (CPACK_RPM_PACKAGE_LICENSE "ISC")
 | 
			
		||||
set (CPACK_RPM_PACKAGE_URL "${project_URL}")
 | 
			
		||||
 | 
			
		||||
set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
 | 
			
		||||
set (CPACK_SOURCE_IGNORE_FILES "/.git;/build;/win32-depends;/liblogdiag/ld-marshal.[ch]")
 | 
			
		||||
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${project_VERSION}")
 | 
			
		||||
set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user;/win32-depends;/liblogdiag/ld-marshal.[ch]")
 | 
			
		||||
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
 | 
			
		||||
 | 
			
		||||
include (CPack)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										38
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						@@ -1,26 +1,12 @@
 | 
			
		||||
Copyright Premysl 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.
 | 
			
		||||
    * 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.
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2010 - 2021, Přemysl Eric Janouch <p@janouch.name>
 | 
			
		||||
 | 
			
		||||
Permission to use, copy, modify, and/or distribute this software for any
 | 
			
		||||
purpose with or without fee is hereby granted.
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										42
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						@@ -1,3 +1,45 @@
 | 
			
		||||
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.
 | 
			
		||||
 - This is the last version supporting Windows XP (we use an outdated GTK+
 | 
			
		||||
   bundle, support for this operating system has been dropped in version 3.18).
 | 
			
		||||
 - 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
 | 
			
		||||
 - Rotation of symbols made possible.
 | 
			
		||||
 - Connections can also be created at ends of other connections.
 | 
			
		||||
 - Added more symbols.
 | 
			
		||||
 - Internationalization, added Czech translation.
 | 
			
		||||
 - Visual enhancement of symbol menus.
 | 
			
		||||
 - The grid is drawn much faster.
 | 
			
		||||
 - Diagrams can be opened from command line.
 | 
			
		||||
 - The diagram file type is registered on Windows.
 | 
			
		||||
 | 
			
		||||
Version 0.1.0
 | 
			
		||||
 - The first release.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										122
									
								
								README.adoc
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,122 @@
 | 
			
		||||
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 from Archlinux's AUR.
 | 
			
		||||
 | 
			
		||||
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.  Add both to 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 (note that Windows XP is no longer able to
 | 
			
		||||
download from HTTPS sources, you'll have to run this externally):
 | 
			
		||||
 | 
			
		||||
 > cmake -P Win32Depends.cmake
 | 
			
		||||
 | 
			
		||||
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 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.
 | 
			
		||||
							
								
								
									
										46
									
								
								README.md
									
									
									
									
									
								
							
							
						
						@@ -1,46 +0,0 @@
 | 
			
		||||
# logdiag
 | 
			
		||||
 | 
			
		||||
logdiag is a schematic editor written in GTK+. It focuses on simplicity,  
 | 
			
		||||
usability and openness.  
 | 
			
		||||
 | 
			
		||||
__This software is considered to be alpha quality and cannot be recommended  
 | 
			
		||||
for regular usage.__  
 | 
			
		||||
 | 
			
		||||
## Requirements
 | 
			
		||||
 | 
			
		||||
Runtime dependencies:  
 | 
			
		||||
 | 
			
		||||
 - GTK+ >= 2.12
 | 
			
		||||
 - json-glib >= 0.10.4
 | 
			
		||||
 - lua = 5.1
 | 
			
		||||
 - librsvg >= 2.0
 | 
			
		||||
 | 
			
		||||
Build dependencies:  
 | 
			
		||||
 | 
			
		||||
 - CMake >= 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
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								ToolchainCrossMinGW.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,16 @@
 | 
			
		||||
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")
 | 
			
		||||
 | 
			
		||||
# Not needed to crosscompile an installation package
 | 
			
		||||
#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)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								ToolchainCrossMinGWW64.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,16 @@
 | 
			
		||||
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")
 | 
			
		||||
 | 
			
		||||
# Not needed to crosscompile an installation package
 | 
			
		||||
#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)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								ToolchainCrossWin64.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,16 @@
 | 
			
		||||
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")
 | 
			
		||||
 | 
			
		||||
# Not needed to crosscompile an installation package
 | 
			
		||||
#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)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										37
									
								
								Win32Cleanup.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,37 @@
 | 
			
		||||
# 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})
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
# 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
 | 
			
		||||
set (working_dir ${CMAKE_CURRENT_BINARY_DIR}/win32-depends)
 | 
			
		||||
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 ${pkg_dir})
 | 
			
		||||
 | 
			
		||||
@@ -18,58 +18,36 @@ if (files)
 | 
			
		||||
endif (files)
 | 
			
		||||
 | 
			
		||||
# Packages
 | 
			
		||||
set (pkg_list "bsdtar" "gtk" "opensuse" "mingw_lua")
 | 
			
		||||
 | 
			
		||||
set (pkg_bsdtar_root "http://sourceforge.net/projects/mingw/files/MinGW")
 | 
			
		||||
set (pkg_bsdtar_urls
 | 
			
		||||
	"${pkg_bsdtar_root}/libarchive/libarchive-2.8.3-1/bsdtar-2.8.3-1-mingw32-bin.tar.bz2"
 | 
			
		||||
	"${pkg_bsdtar_root}/libarchive/libarchive-2.8.3-1/libarchive-2.8.3-1-mingw32-dll-2.tar.bz2"
 | 
			
		||||
	"${pkg_bsdtar_root}/expat/expat-2.0.1-1/libexpat-2.0.1-1-mingw32-dll-1.tar.gz"
 | 
			
		||||
	"${pkg_bsdtar_root}/xz/xz-4.999.9beta_20100401-1/liblzma-4.999.9beta_20100401-1-mingw32-dll-1.tar.bz2"
 | 
			
		||||
	"${pkg_bsdtar_root}/bzip2/release%201.0.5-2/libbz2-1.0.5-2-mingw32-dll-2.tar.gz"
 | 
			
		||||
	"${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_list "gtk" "gtkalt" "winlibs" "mingw_lua")
 | 
			
		||||
 | 
			
		||||
set (pkg_gtk_root "http://ftp.gnome.org/pub/gnome/binaries/win32")
 | 
			
		||||
set (pkg_gtk_urls
 | 
			
		||||
	"${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"
 | 
			
		||||
	"${pkg_gtk_root}/dependencies/gettext-runtime-0.17-1.zip")
 | 
			
		||||
set (pkg_gtk_md5
 | 
			
		||||
	"a545c0ca1e6a312701d42a18e49572af"
 | 
			
		||||
	"2c712a8d7a652363241c0967098515db"
 | 
			
		||||
	"b09662bc99c5c1b8edb8af32a1722477"
 | 
			
		||||
	"bf4e34f1f175b88430159d33e01d0c49"
 | 
			
		||||
	"2d90c71404be0de4e5f3259f63a3e278"
 | 
			
		||||
	"bd6b3d8c35e06a00937db65887c6e287"
 | 
			
		||||
	"b6f59b70eef0992df37f8db891d4b283")
 | 
			
		||||
	"09baff956ebd1c391c7f71e9bd768edd"
 | 
			
		||||
	"110394b4b1e0a50cd440f1e8729d159c")
 | 
			
		||||
 | 
			
		||||
set (pkg_opensuse_root "http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Factory/noarch")
 | 
			
		||||
set (pkg_opensuse_urls
 | 
			
		||||
	"${pkg_opensuse_root}/mingw32-libjson-glib-0.12.0-2.38.noarch.rpm"
 | 
			
		||||
	"${pkg_opensuse_root}/mingw32-json-glib-devel-0.12.0-2.38.noarch.rpm")
 | 
			
		||||
set (pkg_opensuse_strip "usr/i686-pc-mingw32/sys-root/mingw")
 | 
			
		||||
set (pkg_opensuse_md5
 | 
			
		||||
	"2ca72896a3888c9081104e16a996a234"
 | 
			
		||||
	"1c50ab8368b54f9ddf14dbca001477b9")
 | 
			
		||||
# https://sourceforge.net/projects/urlget/files
 | 
			
		||||
# /GTK%2B%203%20binary%20for%20Windows/GTK%2B%203.16.6/
 | 
			
		||||
# contains a binary bundle that may be more or less simply transplanted over,
 | 
			
		||||
# due to ABI compatibility, however something is wrong with icons,
 | 
			
		||||
# and it looks alien on Windows XP (use themes) for close to no improvement.
 | 
			
		||||
set (pkg_gtkalt_root "https://download.geany.org/contrib/gtk")
 | 
			
		||||
set (pkg_gtkalt_urls "${pkg_gtkalt_root}/gtk+-bundle_3.8.2-20131001_win32.zip")
 | 
			
		||||
set (pkg_gtkalt_md5 "3f9b159207edf44937f209b4a5e6bb63")
 | 
			
		||||
 | 
			
		||||
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_winlibs_root "http://sourceforge.net/projects/winlibs/files")
 | 
			
		||||
set (pkg_winlibs_urls "${pkg_winlibs_root}/GTK+/libjson-glib-1.0-1-mingw32.7z")
 | 
			
		||||
set (pkg_winlibs_md5 "f06e42c5998dae5fb6245fecc96a403e")
 | 
			
		||||
 | 
			
		||||
set (pkg_mingw_lua_root "http://sourceforge.net/projects/mingw/files/MinGW/Extension")
 | 
			
		||||
set (pkg_mingw_lua_urls
 | 
			
		||||
	"${pkg_mingw_lua_root}/${pkg_mingw_lua_name}/${pkg_mingw_lua_name}.zip")
 | 
			
		||||
set (pkg_mingw_lua_strip ${pkg_mingw_lua_name})
 | 
			
		||||
	"${pkg_mingw_lua_root}/lua/lua-5.2.0-1/lua-5.2.0-1-mingw32-dll-52.tar.xz"
 | 
			
		||||
	"${pkg_mingw_lua_root}/lua/lua-5.2.0-1/lua-5.2.0-1-mingw32-dev.tar.xz")
 | 
			
		||||
set (pkg_mingw_lua_md5
 | 
			
		||||
	"7deb1f62a9631871e9b90c0419c2e2bb")
 | 
			
		||||
	"150b27cab05b78ba40bbd7225630c00d"
 | 
			
		||||
	"6abe77c1e1a783075fe73c53b7c235fb")
 | 
			
		||||
 | 
			
		||||
# Stage 1: fetch missing packages
 | 
			
		||||
foreach (pkg_set ${pkg_list})
 | 
			
		||||
@@ -80,13 +58,14 @@ foreach (pkg_set ${pkg_list})
 | 
			
		||||
		set (filename ${pkg_dir}/${basename})
 | 
			
		||||
 | 
			
		||||
		if (NOT pkg_md5)
 | 
			
		||||
			message (WARNING "Checksum missing for ${basename}")
 | 
			
		||||
			message (WARNING "MD5 checksum missing for ${basename}")
 | 
			
		||||
			set (pkg_md5_sum)
 | 
			
		||||
			set (pkg_md5_param)
 | 
			
		||||
		else (NOT pkg_md5)
 | 
			
		||||
			list (GET pkg_md5 0 pkg_md5_param)
 | 
			
		||||
		else ()
 | 
			
		||||
			list (GET pkg_md5 0 pkg_md5_sum)
 | 
			
		||||
			list (REMOVE_AT pkg_md5 0)
 | 
			
		||||
			set (pkg_md5_param EXPECTED_MD5 ${pkg_md5_param})
 | 
			
		||||
		endif (NOT pkg_md5)
 | 
			
		||||
			set (pkg_md5_param EXPECTED_MD5 ${pkg_md5_sum})
 | 
			
		||||
		endif ()
 | 
			
		||||
 | 
			
		||||
		if (NOT EXISTS ${filename})
 | 
			
		||||
			message (STATUS "Downloading ${url}...")
 | 
			
		||||
@@ -98,71 +77,39 @@ foreach (pkg_set ${pkg_list})
 | 
			
		||||
				file (REMOVE ${filename})
 | 
			
		||||
				message (FATAL_ERROR "Download failed: ${status_msg}")
 | 
			
		||||
			endif (status_errno)
 | 
			
		||||
		endif (NOT EXISTS ${filename})
 | 
			
		||||
		elseif (pkg_md5_sum)
 | 
			
		||||
			execute_process (COMMAND ${CMAKE_COMMAND} -E md5sum ${filename}
 | 
			
		||||
				OUTPUT_VARIABLE output)
 | 
			
		||||
			if (NOT output MATCHES "^${pkg_md5_sum}")
 | 
			
		||||
				message (FATAL_ERROR "MD5 mismatch for ${basename}")
 | 
			
		||||
			endif (NOT output MATCHES "^${pkg_md5_sum}")
 | 
			
		||||
		endif ()
 | 
			
		||||
	endforeach (url)
 | 
			
		||||
endforeach (pkg_set)
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
# Stage 2: extract the rest of packages
 | 
			
		||||
foreach (pkg_set ${pkg_list})
 | 
			
		||||
	foreach (url ${pkg_${pkg_set}_urls})
 | 
			
		||||
		get_filename_component (filename ${url} NAME)
 | 
			
		||||
		message (STATUS "Extracting ${filename}...")
 | 
			
		||||
 | 
			
		||||
		set (filename ${pkg_dir}/${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}
 | 
			
		||||
				RESULT_VARIABLE status)
 | 
			
		||||
		endif (pkg_${pkg_set}_strip)
 | 
			
		||||
 | 
			
		||||
		execute_process (COMMAND ${CMAKE_COMMAND} -E tar xf ${filename}
 | 
			
		||||
			WORKING_DIRECTORY ${working_dir}
 | 
			
		||||
			RESULT_VARIABLE status)
 | 
			
		||||
		if (status)
 | 
			
		||||
			message (FATAL_ERROR "Extraction failed: ${status}")
 | 
			
		||||
		endif (status)
 | 
			
		||||
		endif ()
 | 
			
		||||
	endforeach (url)
 | 
			
		||||
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 ${working_dir}/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
 | 
			
		||||
	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 (file)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										74
									
								
								Win64Depends.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,74 @@
 | 
			
		||||
#!/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]) }' "$@" | 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
 | 
			
		||||
	for i in packages/*
 | 
			
		||||
	do bsdtar -xf "$i" --strip-components 1 mingw64
 | 
			
		||||
	done
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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,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?
 | 
			
		||||
export XDG_DATA_DIRS=$(pwd)/share
 | 
			
		||||
							
								
								
									
										156
									
								
								cmake/FindCppCheck.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,156 @@
 | 
			
		||||
# - 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)
 | 
			
		||||
 | 
			
		||||
@@ -1,587 +0,0 @@
 | 
			
		||||
# - 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_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()
 | 
			
		||||
 | 
			
		||||
@@ -1,105 +0,0 @@
 | 
			
		||||
# - 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 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)
 | 
			
		||||
 | 
			
		||||
if (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE)
 | 
			
		||||
	set (GETTEXT_FOUND TRUE)
 | 
			
		||||
else (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE)
 | 
			
		||||
	set (GETTEXT_FOUND FALSE)
 | 
			
		||||
	if (GetText_REQUIRED)
 | 
			
		||||
		message (FATAL_ERROR "GetText not found")
 | 
			
		||||
	endif (GetText_REQUIRED)
 | 
			
		||||
endif (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,373 +0,0 @@
 | 
			
		||||
# - 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)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,12 +1,11 @@
 | 
			
		||||
# - Find json-glib
 | 
			
		||||
# This module looks for json-glib.
 | 
			
		||||
# - Find libintl
 | 
			
		||||
# This module looks for libintl.
 | 
			
		||||
# This module defines the following values:
 | 
			
		||||
#    JSON_GLIB_FOUND
 | 
			
		||||
#    JSON_GLIB_INCLUDE_DIRS
 | 
			
		||||
#    JSON_GLIB_LIBRARIES
 | 
			
		||||
#    LIBINTL_FOUND
 | 
			
		||||
#    LIBINTL_LIBRARIES
 | 
			
		||||
 | 
			
		||||
#=============================================================================
 | 
			
		||||
# Copyright Přemysl Janouch 2010
 | 
			
		||||
# Copyright 2011 Přemysl Eric Janouch
 | 
			
		||||
# All rights reserved.
 | 
			
		||||
#
 | 
			
		||||
# Redistribution and use in source and binary forms, with or without
 | 
			
		||||
@@ -30,29 +29,10 @@
 | 
			
		||||
# 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)
 | 
			
		||||
find_library (LIBINTL_LIBRARIES intl)
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS (LibIntl DEFAULT_MSG LIBINTL_LIBRARIES)
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
mark_as_advanced (LIBINTL_LIBRARIES)
 | 
			
		||||
 | 
			
		||||
@@ -22,7 +22,7 @@
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
#=============================================================================
 | 
			
		||||
# Copyright Přemysl Janouch 2010
 | 
			
		||||
# Copyright 2010 Přemysl Eric Janouch
 | 
			
		||||
# All rights reserved.
 | 
			
		||||
#
 | 
			
		||||
# Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										41
									
								
								config.h.in
									
									
									
									
									
								
							
							
						
						@@ -9,48 +9,35 @@
 | 
			
		||||
#define __CONFIG_H__
 | 
			
		||||
 | 
			
		||||
#define PROJECT_NAME "${PROJECT_NAME}"
 | 
			
		||||
#define PROJECT_VERSION "${project_VERSION}"
 | 
			
		||||
#define PROJECT_VERSION "${PROJECT_VERSION}"
 | 
			
		||||
#define PROJECT_URL "${project_URL}"
 | 
			
		||||
 | 
			
		||||
#if ${OPTION_NOINSTALL}
 | 
			
		||||
#cmakedefine OPTION_NOINSTALL
 | 
			
		||||
 | 
			
		||||
#ifdef OPTION_NOINSTALL
 | 
			
		||||
	/* For developers. */
 | 
			
		||||
	#define PROJECT_DOC_DIR "${CMAKE_SOURCE_DIR}/docs/"
 | 
			
		||||
	#define PROJECT_SHARE_DIR "${CMAKE_SOURCE_DIR}/share/"
 | 
			
		||||
	#define PROJECT_GSETTINGS_DIR "${CMAKE_BINARY_DIR}"
 | 
			
		||||
#elif defined (_WIN32)
 | 
			
		||||
	#define PROJECT_DOC_DIR "share/doc/${PROJECT_NAME}/"
 | 
			
		||||
	#define PROJECT_SHARE_DIR "share/${PROJECT_NAME}/"
 | 
			
		||||
#else
 | 
			
		||||
	#define PROJECT_DOC_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}/"
 | 
			
		||||
	#define PROJECT_SHARE_DIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#cmakedefine HAVE_SANE___RESTRICT
 | 
			
		||||
#cmakedefine HAVE_RESTRICT
 | 
			
		||||
#include <glib/gi18n.h>
 | 
			
		||||
 | 
			
		||||
#cmakedefine HAVE_GETTEXT
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define Q_(s) (s)
 | 
			
		||||
#ifdef HAVE_GETTEXT
 | 
			
		||||
	#include <locale.h>
 | 
			
		||||
	#include <libintl.h>
 | 
			
		||||
	#define _(s) gettext(s)
 | 
			
		||||
	#define N_(s1, s2, n) ngettext(s1, s2, n)
 | 
			
		||||
 | 
			
		||||
	#define GETTEXT_DOMAIN "${PROJECT_NAME}"
 | 
			
		||||
#define GETTEXT_DOMAIN "${PROJECT_NAME}"
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
	#define GETTEXT_DIRNAME "share/locale"
 | 
			
		||||
#else
 | 
			
		||||
	#define GETTEXT_DIRNAME "${CMAKE_INSTALL_PREFIX}/share/locale"
 | 
			
		||||
#else /* ! HAVE_GETTEXT */
 | 
			
		||||
	#define _(s) (s)
 | 
			
		||||
	#define N_(s1, s2, n) ((n) == 1 ? (s1) : (s2))
 | 
			
		||||
#endif /* ! HAVE_GETTEXT */
 | 
			
		||||
#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. */
 | 
			
		||||
#define json_object_set_member(object, name, node) \
 | 
			
		||||
	G_STMT_START { \
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								docs/user-guide/create-connection-begin.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 1.1 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								docs/user-guide/create-connection-end.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 1.1 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								docs/user-guide/gitea.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 46 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								docs/user-guide/logdiag-cs.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 22 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								docs/user-guide/logdiag-en.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 22 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								docs/user-guide/select-objects.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3.6 KiB  | 
							
								
								
									
										7
									
								
								docs/user-guide/stylesheet.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,7 @@
 | 
			
		||||
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: " — "; }
 | 
			
		||||
							
								
								
									
										141
									
								
								docs/user-guide/user-guide-cs.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,141 @@
 | 
			
		||||
<!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.2.0,</span>
 | 
			
		||||
<span id="revdate">2018-06-27</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">
 | 
			
		||||
 … 
 | 
			
		||||
<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>Jak můžu diagram vytisknout?</h3>
 | 
			
		||||
<p>Současná verze aplikace není schopná přímo tisknout. Pro vytištění
 | 
			
		||||
vytvořeného diagramu můžete klávesou PrintScreen sejmout snímek obrazovky,
 | 
			
		||||
vložit jej například do aplikace Malování, oříznout požadovanou část
 | 
			
		||||
a vytisknout ji z tohoto grafického editoru.
 | 
			
		||||
 | 
			
		||||
<h3>Schází mi popisky</h3>
 | 
			
		||||
<p>Obdobně jako v předchozím případě tato funkcionalita zatím neexistuje,
 | 
			
		||||
ale je možné tento nedostatek obejít přes běžný grafický editor.
 | 
			
		||||
 | 
			
		||||
<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>
 | 
			
		||||
							
								
								
									
										133
									
								
								docs/user-guide/user-guide-en.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,133 @@
 | 
			
		||||
<!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.2.0,</span>
 | 
			
		||||
<span id="revdate">2018-06-27</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 it’s 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 that’s 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, don’t 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">
 | 
			
		||||
 … 
 | 
			
		||||
<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>Can’t open a saved diagram</h3>
 | 
			
		||||
<p>When saving, ensure that the filename you’ve typed in contains the
 | 
			
		||||
<q>.ldd</q> suffix. If not, it won’t show up in the dialog for opening diagrams.
 | 
			
		||||
In case you’ve already saved a file without an extension, you may fix this
 | 
			
		||||
situation by adding the suffix to its name.
 | 
			
		||||
 | 
			
		||||
<h3>How do I print a diagram?</h3>
 | 
			
		||||
<p>The current version of application is not able to print directly. To print
 | 
			
		||||
out a created diagram, you may use the PrintScreen key to capture a screenshot,
 | 
			
		||||
then insert it to, for example, Paint, and print it from inside the graphics
 | 
			
		||||
editor.
 | 
			
		||||
 | 
			
		||||
<h3>I miss labels</h3>
 | 
			
		||||
<p>Similarly to the previous case, this functionality doesn’t exist yet, but it
 | 
			
		||||
is possible to get around this limitation using a graphics editor.
 | 
			
		||||
 | 
			
		||||
<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>
 | 
			
		||||
@@ -1,95 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * ld-canvas.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef __LD_CANVAS_H__
 | 
			
		||||
#define __LD_CANVAS_H__
 | 
			
		||||
 | 
			
		||||
G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define LD_TYPE_CANVAS (ld_canvas_get_type ())
 | 
			
		||||
#define LD_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST \
 | 
			
		||||
	((obj), LD_TYPE_CANVAS, LdCanvas))
 | 
			
		||||
#define LD_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
 | 
			
		||||
	((klass), LD_TYPE_CANVAS, LdCanvasClass))
 | 
			
		||||
#define LD_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((obj), LD_TYPE_CANVAS))
 | 
			
		||||
#define LD_IS_CANVAS_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((klass), LD_TYPE_CANVAS))
 | 
			
		||||
#define LD_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
 | 
			
		||||
	((obj), LD_CANVAS, LdCanvasClass))
 | 
			
		||||
 | 
			
		||||
typedef struct _LdCanvas LdCanvas;
 | 
			
		||||
typedef struct _LdCanvasPrivate LdCanvasPrivate;
 | 
			
		||||
typedef struct _LdCanvasClass LdCanvasClass;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * LdCanvas:
 | 
			
		||||
 */
 | 
			
		||||
struct _LdCanvas
 | 
			
		||||
{
 | 
			
		||||
/*< private >*/
 | 
			
		||||
	GtkDrawingArea parent_instance;
 | 
			
		||||
	LdCanvasPrivate *priv;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct _LdCanvasClass
 | 
			
		||||
{
 | 
			
		||||
/*< private >*/
 | 
			
		||||
	GtkDrawingAreaClass parent_class;
 | 
			
		||||
 | 
			
		||||
	guint cancel_operation_signal;
 | 
			
		||||
	guint move_signal;
 | 
			
		||||
 | 
			
		||||
	void (*set_scroll_adjustments) (LdCanvas *self,
 | 
			
		||||
		GtkAdjustment *horizontal, GtkAdjustment *vertical);
 | 
			
		||||
	void (*cancel_operation) (LdCanvas *self);
 | 
			
		||||
	void (*move) (LdCanvas *self, gdouble dx, gdouble dy);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * LD_CANVAS_BASE_UNIT_LENGTH:
 | 
			
		||||
 *
 | 
			
		||||
 * Length of the base unit in milimetres.
 | 
			
		||||
 */
 | 
			
		||||
#define LD_CANVAS_BASE_UNIT_LENGTH 2.5
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
GType ld_canvas_get_type (void) G_GNUC_CONST;
 | 
			
		||||
 | 
			
		||||
GtkWidget *ld_canvas_new (void);
 | 
			
		||||
 | 
			
		||||
void ld_canvas_set_diagram (LdCanvas *self, LdDiagram *diagram);
 | 
			
		||||
LdDiagram *ld_canvas_get_diagram (LdCanvas *self);
 | 
			
		||||
void ld_canvas_set_library (LdCanvas *self, LdLibrary *library);
 | 
			
		||||
LdLibrary *ld_canvas_get_library (LdCanvas *self);
 | 
			
		||||
 | 
			
		||||
void ld_canvas_widget_to_diagram_coords (LdCanvas *self,
 | 
			
		||||
	gdouble wx, gdouble wy, gdouble *dx, gdouble *dy);
 | 
			
		||||
void ld_canvas_diagram_to_widget_coords (LdCanvas *self,
 | 
			
		||||
	gdouble dx, gdouble dy, gdouble *wx, gdouble *wy);
 | 
			
		||||
 | 
			
		||||
gdouble ld_canvas_get_zoom (LdCanvas *self);
 | 
			
		||||
void ld_canvas_set_zoom (LdCanvas *self, gdouble zoom);
 | 
			
		||||
gboolean ld_canvas_can_zoom_in (LdCanvas *self);
 | 
			
		||||
void ld_canvas_zoom_in (LdCanvas *self);
 | 
			
		||||
gboolean ld_canvas_can_zoom_out (LdCanvas *self);
 | 
			
		||||
void ld_canvas_zoom_out (LdCanvas *self);
 | 
			
		||||
 | 
			
		||||
void ld_canvas_add_object_begin (LdCanvas *self, LdDiagramObject *object);
 | 
			
		||||
 | 
			
		||||
/* TODO: The rest of the interface. */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_CANVAS_H__ */
 | 
			
		||||
							
								
								
									
										630
									
								
								liblogdiag/ld-category-symbol-view.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,630 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										64
									
								
								liblogdiag/ld-category-symbol-view.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,64 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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__ */
 | 
			
		||||
							
								
								
									
										342
									
								
								liblogdiag/ld-category-tree-view.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,342 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										64
									
								
								liblogdiag/ld-category-tree-view.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,64 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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__ */
 | 
			
		||||
							
								
								
									
										98
									
								
								liblogdiag/ld-category-view.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,98 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										59
									
								
								liblogdiag/ld-category-view.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,59 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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__ */
 | 
			
		||||
							
								
								
									
										563
									
								
								liblogdiag/ld-category.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,563 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										79
									
								
								liblogdiag/ld-category.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,79 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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__ */
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-diagram-connection.c
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * 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,
 | 
			
		||||
	LD_TYPE_DIAGRAM_OBJECT);
 | 
			
		||||
	LD_TYPE_DIAGRAM_OBJECT)
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
ld_diagram_connection_class_init (LdDiagramConnectionClass *klass)
 | 
			
		||||
@@ -98,7 +98,7 @@ ld_diagram_connection_get_property (GObject *object, guint property_id,
 | 
			
		||||
 | 
			
		||||
	case PROP_POINTS:
 | 
			
		||||
		points = ld_diagram_connection_get_points (self);
 | 
			
		||||
		g_value_set_boxed_take_ownership (value, points);
 | 
			
		||||
		g_value_take_boxed (value, points);
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 | 
			
		||||
@@ -332,4 +332,3 @@ on_set_points_destroy (gpointer user_data)
 | 
			
		||||
		json_node_free (data->new_node);
 | 
			
		||||
	g_slice_free (SetPointsActionData, data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-diagram-connection.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -15,16 +15,22 @@ G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define LD_TYPE_DIAGRAM_CONNECTION (ld_diagram_connection_get_type ())
 | 
			
		||||
#define LD_DIAGRAM_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST \
 | 
			
		||||
	((obj), LD_TYPE_DIAGRAM_CONNECTION, LdDiagramConnection))
 | 
			
		||||
#define LD_DIAGRAM_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
 | 
			
		||||
	((klass), LD_TYPE_DIAGRAM_CONNECTION, LdDiagramConnectionClass))
 | 
			
		||||
#define LD_IS_DIAGRAM_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((obj), LD_TYPE_DIAGRAM_CONNECTION))
 | 
			
		||||
#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))
 | 
			
		||||
#define LD_DIAGRAM_CONNECTION(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
 | 
			
		||||
		LD_TYPE_DIAGRAM_CONNECTION, \
 | 
			
		||||
		LdDiagramConnection))
 | 
			
		||||
#define LD_DIAGRAM_CONNECTION_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_CLASS_CAST ((klass), \
 | 
			
		||||
		LD_TYPE_DIAGRAM_CONNECTION, \
 | 
			
		||||
		LdDiagramConnectionClass))
 | 
			
		||||
#define LD_IS_DIAGRAM_CONNECTION(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_DIAGRAM_CONNECTION))
 | 
			
		||||
#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 _LdDiagramConnectionPrivate LdDiagramConnectionPrivate;
 | 
			
		||||
@@ -61,4 +67,3 @@ void ld_diagram_connection_set_points (LdDiagramConnection *self,
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_DIAGRAM_CONNECTION_H__ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-diagram-object.c
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -17,7 +17,7 @@
 | 
			
		||||
/**
 | 
			
		||||
 * SECTION:ld-diagram-object
 | 
			
		||||
 * @short_description: A diagram object
 | 
			
		||||
 * @see_also: #LdDiagram, #LdCanvas
 | 
			
		||||
 * @see_also: #LdDiagram, #LdDiagramView
 | 
			
		||||
 *
 | 
			
		||||
 * #LdDiagramObject represents an object in an #LdDiagram.
 | 
			
		||||
 */
 | 
			
		||||
@@ -25,10 +25,12 @@
 | 
			
		||||
/*
 | 
			
		||||
 * LdDiagramObjectPrivate:
 | 
			
		||||
 * @storage: storage for object parameters.
 | 
			
		||||
 * @lock_history: lock emitting of changes.
 | 
			
		||||
 */
 | 
			
		||||
struct _LdDiagramObjectPrivate
 | 
			
		||||
{
 | 
			
		||||
	JsonObject *storage;
 | 
			
		||||
	gboolean lock_history;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef struct _SetParamActionData SetParamActionData;
 | 
			
		||||
@@ -67,7 +69,7 @@ static void on_set_param_redo (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
 | 
			
		||||
ld_diagram_object_class_init (LdDiagramObjectClass *klass)
 | 
			
		||||
@@ -219,8 +221,12 @@ JsonObject *
 | 
			
		||||
ld_diagram_object_get_storage (LdDiagramObject *self)
 | 
			
		||||
{
 | 
			
		||||
	g_return_val_if_fail (LD_IS_DIAGRAM_OBJECT (self), NULL);
 | 
			
		||||
 | 
			
		||||
	if (!self->priv->storage)
 | 
			
		||||
	{
 | 
			
		||||
		self->priv->storage = json_object_new ();
 | 
			
		||||
		g_object_notify (G_OBJECT (self), "storage");
 | 
			
		||||
	}
 | 
			
		||||
	return self->priv->storage;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -243,6 +249,8 @@ ld_diagram_object_set_storage (LdDiagramObject *self, JsonObject *storage)
 | 
			
		||||
		self->priv->storage = json_object_ref (storage);
 | 
			
		||||
	else
 | 
			
		||||
		self->priv->storage = NULL;
 | 
			
		||||
 | 
			
		||||
	g_object_notify (G_OBJECT (self), "storage");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -309,7 +317,10 @@ ld_diagram_object_get_data_warn:
 | 
			
		||||
 | 
			
		||||
ld_diagram_object_get_data_default:
 | 
			
		||||
	g_param_value_set_default (pspec, data);
 | 
			
		||||
 | 
			
		||||
	self->priv->lock_history = TRUE;
 | 
			
		||||
	g_object_set_property (G_OBJECT (self), name, data);
 | 
			
		||||
	self->priv->lock_history = FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -328,7 +339,7 @@ ld_diagram_object_set_data_for_param (LdDiagramObject *self,
 | 
			
		||||
	SetParamActionData *action_data;
 | 
			
		||||
	JsonObject *storage;
 | 
			
		||||
	const gchar *name;
 | 
			
		||||
	JsonNode *node;
 | 
			
		||||
	JsonNode *new_node, *old_node;
 | 
			
		||||
 | 
			
		||||
	g_return_if_fail (LD_IS_DIAGRAM_OBJECT (self));
 | 
			
		||||
	g_return_if_fail (G_IS_VALUE (data));
 | 
			
		||||
@@ -337,23 +348,31 @@ ld_diagram_object_set_data_for_param (LdDiagramObject *self,
 | 
			
		||||
	storage = ld_diagram_object_get_storage (self);
 | 
			
		||||
	name = g_param_spec_get_name (pspec);
 | 
			
		||||
 | 
			
		||||
	action_data = g_slice_new (SetParamActionData);
 | 
			
		||||
	action_data->self = g_object_ref (self);
 | 
			
		||||
	action_data->param_name = g_strdup (g_param_spec_get_name (pspec));
 | 
			
		||||
	if (!self->priv->lock_history)
 | 
			
		||||
	{
 | 
			
		||||
		action_data = g_slice_new (SetParamActionData);
 | 
			
		||||
		action_data->self = g_object_ref (self);
 | 
			
		||||
		action_data->param_name = g_strdup (g_param_spec_get_name (pspec));
 | 
			
		||||
 | 
			
		||||
	node = json_object_get_member (storage, name);
 | 
			
		||||
	action_data->old_node = node ? json_node_copy (node) : NULL;
 | 
			
		||||
		old_node = json_object_get_member (storage, name);
 | 
			
		||||
		action_data->old_node = old_node ? json_node_copy (old_node) : NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	node = json_node_new (JSON_NODE_VALUE);
 | 
			
		||||
	json_node_set_value (node, data);
 | 
			
		||||
	action_data->new_node = json_node_copy (node);
 | 
			
		||||
	new_node = json_node_new (JSON_NODE_VALUE);
 | 
			
		||||
	json_node_set_value (new_node, data);
 | 
			
		||||
 | 
			
		||||
	json_object_set_member (storage, name, node);
 | 
			
		||||
	if (!self->priv->lock_history)
 | 
			
		||||
		action_data->new_node = json_node_copy (new_node);
 | 
			
		||||
 | 
			
		||||
	action = ld_undo_action_new (on_set_param_undo, on_set_param_redo,
 | 
			
		||||
		on_set_param_destroy, action_data);
 | 
			
		||||
	ld_diagram_object_changed (self, action);
 | 
			
		||||
	g_object_unref (action);
 | 
			
		||||
	json_object_set_member (storage, name, new_node);
 | 
			
		||||
 | 
			
		||||
	if (!self->priv->lock_history)
 | 
			
		||||
	{
 | 
			
		||||
		action = ld_undo_action_new (on_set_param_undo, on_set_param_redo,
 | 
			
		||||
			on_set_param_destroy, action_data);
 | 
			
		||||
		ld_diagram_object_changed (self, action);
 | 
			
		||||
		g_object_unref (action);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-diagram-object.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -15,16 +15,20 @@ G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define LD_TYPE_DIAGRAM_OBJECT (ld_diagram_object_get_type ())
 | 
			
		||||
#define LD_DIAGRAM_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST \
 | 
			
		||||
	((obj), LD_TYPE_DIAGRAM_OBJECT, LdDiagramObject))
 | 
			
		||||
#define LD_DIAGRAM_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
 | 
			
		||||
	((klass), LD_TYPE_DIAGRAM_OBJECT, LdDiagramObjectClass))
 | 
			
		||||
#define LD_IS_DIAGRAM_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((obj), LD_TYPE_DIAGRAM_OBJECT))
 | 
			
		||||
#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))
 | 
			
		||||
#define LD_DIAGRAM_OBJECT(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
 | 
			
		||||
		LD_TYPE_DIAGRAM_OBJECT, \
 | 
			
		||||
		LdDiagramObject))
 | 
			
		||||
#define LD_DIAGRAM_OBJECT_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_CLASS_CAST ((klass), \
 | 
			
		||||
		LD_TYPE_DIAGRAM_OBJECT, \
 | 
			
		||||
		LdDiagramObjectClass))
 | 
			
		||||
#define LD_IS_DIAGRAM_OBJECT(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_DIAGRAM_OBJECT))
 | 
			
		||||
#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 _LdDiagramObjectPrivate LdDiagramObjectPrivate;
 | 
			
		||||
@@ -74,4 +78,3 @@ void ld_diagram_object_set_y (LdDiagramObject *self, gdouble y);
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_DIAGRAM_OBJECT_H__ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-diagram-symbol.c
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -23,7 +23,8 @@
 | 
			
		||||
enum
 | 
			
		||||
{
 | 
			
		||||
	PROP_0,
 | 
			
		||||
	PROP_CLASS
 | 
			
		||||
	PROP_CLASS,
 | 
			
		||||
	PROP_ROTATION
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static void ld_diagram_symbol_get_property (GObject *object, guint property_id,
 | 
			
		||||
@@ -32,7 +33,7 @@ static void ld_diagram_symbol_set_property (GObject *object, guint property_id,
 | 
			
		||||
	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
 | 
			
		||||
ld_diagram_symbol_class_init (LdDiagramSymbolClass *klass)
 | 
			
		||||
@@ -53,6 +54,16 @@ ld_diagram_symbol_class_init (LdDiagramSymbolClass *klass)
 | 
			
		||||
		"The class of this symbol.",
 | 
			
		||||
		"", G_PARAM_READWRITE);
 | 
			
		||||
	g_object_class_install_property (object_class, PROP_CLASS, pspec);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * LdDiagramSymbol:rotation:
 | 
			
		||||
 *
 | 
			
		||||
 * Rotation of this symbol.
 | 
			
		||||
 */
 | 
			
		||||
	pspec = g_param_spec_int ("rotation", "Rotation",
 | 
			
		||||
		"Rotation of this symbol.",
 | 
			
		||||
		0, 3, 0, G_PARAM_READWRITE);
 | 
			
		||||
	g_object_class_install_property (object_class, PROP_ROTATION, pspec);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
@@ -70,6 +81,7 @@ ld_diagram_symbol_get_property (GObject *object, guint property_id,
 | 
			
		||||
	switch (property_id)
 | 
			
		||||
	{
 | 
			
		||||
	case PROP_CLASS:
 | 
			
		||||
	case PROP_ROTATION:
 | 
			
		||||
		ld_diagram_object_get_data_for_param (self, value, pspec);
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
@@ -87,6 +99,7 @@ ld_diagram_symbol_set_property (GObject *object, guint property_id,
 | 
			
		||||
	switch (property_id)
 | 
			
		||||
	{
 | 
			
		||||
	case PROP_CLASS:
 | 
			
		||||
	case PROP_ROTATION:
 | 
			
		||||
		ld_diagram_object_set_data_for_param (self, value, pspec);
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
@@ -139,3 +152,33 @@ ld_diagram_symbol_set_class (LdDiagramSymbol *self, const gchar *klass)
 | 
			
		||||
	g_return_if_fail (LD_IS_DIAGRAM_SYMBOL (self));
 | 
			
		||||
	g_object_set (self, "class", klass, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ld_diagram_symbol_get_rotation:
 | 
			
		||||
 * @self: an #LdDiagramSymbol object.
 | 
			
		||||
 *
 | 
			
		||||
 * Return value: rotation of the symbol.
 | 
			
		||||
 */
 | 
			
		||||
gint
 | 
			
		||||
ld_diagram_symbol_get_rotation (LdDiagramSymbol *self)
 | 
			
		||||
{
 | 
			
		||||
	gint rotation;
 | 
			
		||||
 | 
			
		||||
	g_return_val_if_fail (LD_IS_DIAGRAM_SYMBOL (self), 0);
 | 
			
		||||
	g_object_get (self, "rotation", &rotation, NULL);
 | 
			
		||||
	return rotation;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ld_diagram_symbol_set_rotation:
 | 
			
		||||
 * @self: an #LdDiagramSymbol object.
 | 
			
		||||
 * @rotation: the rotation.
 | 
			
		||||
 *
 | 
			
		||||
 * Set rotation of the symbol.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
ld_diagram_symbol_set_rotation (LdDiagramSymbol *self, gint rotation)
 | 
			
		||||
{
 | 
			
		||||
	g_return_if_fail (LD_IS_DIAGRAM_SYMBOL (self));
 | 
			
		||||
	g_object_set (self, "rotation", rotation, NULL);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-diagram-symbol.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -15,16 +15,20 @@ G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define LD_TYPE_DIAGRAM_SYMBOL (ld_diagram_symbol_get_type ())
 | 
			
		||||
#define LD_DIAGRAM_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST \
 | 
			
		||||
	((obj), LD_TYPE_DIAGRAM_SYMBOL, LdDiagramSymbol))
 | 
			
		||||
#define LD_DIAGRAM_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
 | 
			
		||||
	((klass), LD_TYPE_DIAGRAM_SYMBOL, LdDiagramSymbolClass))
 | 
			
		||||
#define LD_IS_DIAGRAM_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((obj), LD_TYPE_DIAGRAM_SYMBOL))
 | 
			
		||||
#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))
 | 
			
		||||
#define LD_DIAGRAM_SYMBOL(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
 | 
			
		||||
		LD_TYPE_DIAGRAM_SYMBOL, \
 | 
			
		||||
		LdDiagramSymbol))
 | 
			
		||||
#define LD_DIAGRAM_SYMBOL_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_CLASS_CAST ((klass), \
 | 
			
		||||
		LD_TYPE_DIAGRAM_SYMBOL, \
 | 
			
		||||
		LdDiagramSymbolClass))
 | 
			
		||||
#define LD_IS_DIAGRAM_SYMBOL(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_DIAGRAM_SYMBOL))
 | 
			
		||||
#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 _LdDiagramSymbolPrivate LdDiagramSymbolPrivate;
 | 
			
		||||
@@ -50,14 +54,23 @@ struct _LdDiagramSymbolClass
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
enum
 | 
			
		||||
{
 | 
			
		||||
	LD_DIAGRAM_SYMBOL_ROTATION_0,
 | 
			
		||||
	LD_DIAGRAM_SYMBOL_ROTATION_90,
 | 
			
		||||
	LD_DIAGRAM_SYMBOL_ROTATION_180,
 | 
			
		||||
	LD_DIAGRAM_SYMBOL_ROTATION_270
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
GType ld_diagram_symbol_get_type (void) G_GNUC_CONST;
 | 
			
		||||
 | 
			
		||||
LdDiagramSymbol *ld_diagram_symbol_new (JsonObject *storage);
 | 
			
		||||
gchar *ld_diagram_symbol_get_class (LdDiagramSymbol *self);
 | 
			
		||||
void ld_diagram_symbol_set_class (LdDiagramSymbol *self, const gchar *klass);
 | 
			
		||||
gint ld_diagram_symbol_get_rotation (LdDiagramSymbol *self);
 | 
			
		||||
void ld_diagram_symbol_set_rotation (LdDiagramSymbol *self, gint rotation);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_DIAGRAM_SYMBOL_H__ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2909
									
								
								liblogdiag/ld-diagram-view.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										102
									
								
								liblogdiag/ld-diagram-view.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,102 @@
 | 
			
		||||
/*
 | 
			
		||||
 * ld-diagram-view.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright 2010, 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef __LD_DIAGRAM_VIEW_H__
 | 
			
		||||
#define __LD_DIAGRAM_VIEW_H__
 | 
			
		||||
 | 
			
		||||
G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define LD_TYPE_DIAGRAM_VIEW (ld_diagram_view_get_type ())
 | 
			
		||||
#define LD_DIAGRAM_VIEW(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_DIAGRAM_VIEW, LdDiagramView))
 | 
			
		||||
#define LD_DIAGRAM_VIEW_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_CLASS_CAST ((klass), \
 | 
			
		||||
		LD_TYPE_DIAGRAM_VIEW, \
 | 
			
		||||
		LdDiagramViewClass))
 | 
			
		||||
#define LD_IS_DIAGRAM_VIEW(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_DIAGRAM_VIEW))
 | 
			
		||||
#define LD_IS_DIAGRAM_VIEW_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_DIAGRAM_VIEW))
 | 
			
		||||
#define LD_DIAGRAM_VIEW_GET_CLASS(obj) \
 | 
			
		||||
	(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_DIAGRAM_VIEW, LdDiagramViewClass))
 | 
			
		||||
 | 
			
		||||
typedef struct _LdDiagramView LdDiagramView;
 | 
			
		||||
typedef struct _LdDiagramViewPrivate LdDiagramViewPrivate;
 | 
			
		||||
typedef struct _LdDiagramViewClass LdDiagramViewClass;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * LdDiagramView:
 | 
			
		||||
 */
 | 
			
		||||
struct _LdDiagramView
 | 
			
		||||
{
 | 
			
		||||
/*< private >*/
 | 
			
		||||
	GtkDrawingArea parent_instance;
 | 
			
		||||
	LdDiagramViewPrivate *priv;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct _LdDiagramViewClass
 | 
			
		||||
{
 | 
			
		||||
/*< private >*/
 | 
			
		||||
	GtkDrawingAreaClass parent_class;
 | 
			
		||||
 | 
			
		||||
	guint cancel_operation_signal;
 | 
			
		||||
	guint move_signal;
 | 
			
		||||
 | 
			
		||||
	void (*cancel_operation) (LdDiagramView *self);
 | 
			
		||||
	void (*move) (LdDiagramView *self, gdouble dx, gdouble dy);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * LD_DIAGRAM_VIEW_BASE_UNIT_LENGTH:
 | 
			
		||||
 *
 | 
			
		||||
 * Length of the base unit in milimetres.
 | 
			
		||||
 */
 | 
			
		||||
#define LD_DIAGRAM_VIEW_BASE_UNIT_LENGTH 2.5
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
GType ld_diagram_view_get_type (void) G_GNUC_CONST;
 | 
			
		||||
 | 
			
		||||
GtkWidget *ld_diagram_view_new (void);
 | 
			
		||||
 | 
			
		||||
void ld_diagram_view_set_diagram (LdDiagramView *self, LdDiagram *diagram);
 | 
			
		||||
LdDiagram *ld_diagram_view_get_diagram (LdDiagramView *self);
 | 
			
		||||
void ld_diagram_view_set_library (LdDiagramView *self, LdLibrary *library);
 | 
			
		||||
LdLibrary *ld_diagram_view_get_library (LdDiagramView *self);
 | 
			
		||||
 | 
			
		||||
void ld_diagram_view_widget_to_diagram_coords (LdDiagramView *self,
 | 
			
		||||
	gdouble wx, gdouble wy, gdouble *dx, gdouble *dy);
 | 
			
		||||
void ld_diagram_view_diagram_to_widget_coords (LdDiagramView *self,
 | 
			
		||||
	gdouble dx, gdouble dy, gdouble *wx, gdouble *wy);
 | 
			
		||||
 | 
			
		||||
gdouble ld_diagram_view_get_x (LdDiagramView *self);
 | 
			
		||||
void ld_diagram_view_set_x (LdDiagramView *self, gdouble x);
 | 
			
		||||
gdouble ld_diagram_view_get_y (LdDiagramView *self);
 | 
			
		||||
void ld_diagram_view_set_y (LdDiagramView *self, gdouble y);
 | 
			
		||||
 | 
			
		||||
gdouble ld_diagram_view_get_zoom (LdDiagramView *self);
 | 
			
		||||
void ld_diagram_view_set_zoom (LdDiagramView *self, gdouble zoom);
 | 
			
		||||
gboolean ld_diagram_view_can_zoom_in (LdDiagramView *self);
 | 
			
		||||
void ld_diagram_view_zoom_in (LdDiagramView *self);
 | 
			
		||||
gboolean ld_diagram_view_can_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,
 | 
			
		||||
	LdDiagramObject *object);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_DIAGRAM_VIEW_H__ */
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-diagram.c
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011, 2012 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -15,7 +15,7 @@
 | 
			
		||||
/**
 | 
			
		||||
 * SECTION:ld-diagram
 | 
			
		||||
 * @short_description: A model for diagrams
 | 
			
		||||
 * @see_also: #LdCanvas
 | 
			
		||||
 * @see_also: #LdDiagramView
 | 
			
		||||
 *
 | 
			
		||||
 * #LdDiagram is a model used for storing diagrams.
 | 
			
		||||
 */
 | 
			
		||||
@@ -31,7 +31,6 @@
 | 
			
		||||
 *              each containing a #GList of #LdUndoAction subactions.
 | 
			
		||||
 * @objects: all objects in the diagram.
 | 
			
		||||
 * @selection: all currently selected objects.
 | 
			
		||||
 * @connections: connections between objects.
 | 
			
		||||
 */
 | 
			
		||||
struct _LdDiagramPrivate
 | 
			
		||||
{
 | 
			
		||||
@@ -43,7 +42,6 @@ struct _LdDiagramPrivate
 | 
			
		||||
 | 
			
		||||
	GList *objects;
 | 
			
		||||
	GList *selection;
 | 
			
		||||
	GList *connections;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef struct _ObjectActionData ObjectActionData;
 | 
			
		||||
@@ -56,7 +54,7 @@ typedef struct _ObjectActionData ObjectActionData;
 | 
			
		||||
 */
 | 
			
		||||
struct _ObjectActionData
 | 
			
		||||
{
 | 
			
		||||
	LdDiagram *self;
 | 
			
		||||
	gpointer self;
 | 
			
		||||
	LdDiagramObject *object;
 | 
			
		||||
	gint pos;
 | 
			
		||||
};
 | 
			
		||||
@@ -76,6 +74,7 @@ static void ld_diagram_set_property (GObject *object, guint property_id,
 | 
			
		||||
static void ld_diagram_dispose (GObject *gobject);
 | 
			
		||||
static void ld_diagram_finalize (GObject *gobject);
 | 
			
		||||
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);
 | 
			
		||||
 | 
			
		||||
@@ -106,7 +105,7 @@ static void uninstall_object (LdDiagramObject *object, 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
 | 
			
		||||
ld_diagram_class_init (LdDiagramClass *klass)
 | 
			
		||||
@@ -232,7 +231,7 @@ ld_diagram_dispose (GObject *gobject)
 | 
			
		||||
	LdDiagram *self;
 | 
			
		||||
 | 
			
		||||
	self = LD_DIAGRAM (gobject);
 | 
			
		||||
	ld_diagram_clear (self);
 | 
			
		||||
	ld_diagram_clear_internal (self, FALSE);
 | 
			
		||||
 | 
			
		||||
	/* Chain up to the parent class. */
 | 
			
		||||
	G_OBJECT_CLASS (ld_diagram_parent_class)->dispose (gobject);
 | 
			
		||||
@@ -286,24 +285,23 @@ ld_diagram_new (void)
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
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 selection_changed = FALSE;
 | 
			
		||||
 | 
			
		||||
	g_return_if_fail (LD_IS_DIAGRAM (self));
 | 
			
		||||
 | 
			
		||||
	if (self->priv->selection)
 | 
			
		||||
	{
 | 
			
		||||
		ld_diagram_unselect_all_internal (self);
 | 
			
		||||
		selection_changed = TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (self->priv->connections)
 | 
			
		||||
	{
 | 
			
		||||
		g_list_free (self->priv->connections);
 | 
			
		||||
		self->priv->connections = NULL;
 | 
			
		||||
		changed = TRUE;
 | 
			
		||||
	}
 | 
			
		||||
	if (self->priv->objects)
 | 
			
		||||
	{
 | 
			
		||||
		g_list_foreach (self->priv->objects, (GFunc) uninstall_object, self);
 | 
			
		||||
@@ -315,15 +313,18 @@ ld_diagram_clear (LdDiagram *self)
 | 
			
		||||
	destroy_action_stack (&self->priv->undo_stack);
 | 
			
		||||
	destroy_action_stack (&self->priv->redo_stack);
 | 
			
		||||
 | 
			
		||||
	g_object_notify (G_OBJECT (self), "can-undo");
 | 
			
		||||
	g_object_notify (G_OBJECT (self), "can-redo");
 | 
			
		||||
	if (emit_signals)
 | 
			
		||||
	{
 | 
			
		||||
		g_object_notify (G_OBJECT (self), "can-undo");
 | 
			
		||||
		g_object_notify (G_OBJECT (self), "can-redo");
 | 
			
		||||
 | 
			
		||||
	if (changed)
 | 
			
		||||
		g_signal_emit (self,
 | 
			
		||||
			LD_DIAGRAM_GET_CLASS (self)->changed_signal, 0);
 | 
			
		||||
	if (selection_changed)
 | 
			
		||||
		g_signal_emit (self,
 | 
			
		||||
			LD_DIAGRAM_GET_CLASS (self)->selection_changed_signal, 0);
 | 
			
		||||
		if (changed)
 | 
			
		||||
			g_signal_emit (self,
 | 
			
		||||
				LD_DIAGRAM_GET_CLASS (self)->changed_signal, 0);
 | 
			
		||||
		if (selection_changed)
 | 
			
		||||
			g_signal_emit (self,
 | 
			
		||||
				LD_DIAGRAM_GET_CLASS (self)->selection_changed_signal, 0);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -809,7 +810,9 @@ on_object_action_remove (gpointer user_data)
 | 
			
		||||
	ObjectActionData *data;
 | 
			
		||||
 | 
			
		||||
	data = user_data;
 | 
			
		||||
	ld_diagram_remove_object (data->self, data->object);
 | 
			
		||||
	g_return_if_fail (data->self != NULL);
 | 
			
		||||
	ld_diagram_remove_object
 | 
			
		||||
		((LdDiagram *) data->self, data->object);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
@@ -818,7 +821,9 @@ on_object_action_insert (gpointer user_data)
 | 
			
		||||
	ObjectActionData *data;
 | 
			
		||||
 | 
			
		||||
	data = user_data;
 | 
			
		||||
	ld_diagram_insert_object (data->self, data->object, data->pos);
 | 
			
		||||
	g_return_if_fail (data->self != NULL);
 | 
			
		||||
	ld_diagram_insert_object
 | 
			
		||||
		((LdDiagram *) data->self, data->object, data->pos);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
@@ -827,7 +832,8 @@ on_object_action_destroy (gpointer user_data)
 | 
			
		||||
	ObjectActionData *data;
 | 
			
		||||
 | 
			
		||||
	data = user_data;
 | 
			
		||||
	g_object_unref (data->self);
 | 
			
		||||
	if (data->self)
 | 
			
		||||
		g_object_remove_weak_pointer (G_OBJECT (data->self), &data->self);
 | 
			
		||||
	g_object_unref (data->object);
 | 
			
		||||
	g_slice_free (ObjectActionData, data);
 | 
			
		||||
}
 | 
			
		||||
@@ -891,7 +897,8 @@ ld_diagram_insert_object (LdDiagram *self, LdDiagramObject *object, gint pos)
 | 
			
		||||
	install_object (object, self);
 | 
			
		||||
 | 
			
		||||
	action_data = g_slice_new (ObjectActionData);
 | 
			
		||||
	action_data->self = g_object_ref (self);
 | 
			
		||||
	action_data->self = self;
 | 
			
		||||
	g_object_add_weak_pointer (G_OBJECT (self), &action_data->self);
 | 
			
		||||
	action_data->object = g_object_ref (object);
 | 
			
		||||
	action_data->pos = pos;
 | 
			
		||||
 | 
			
		||||
@@ -938,7 +945,8 @@ ld_diagram_remove_object (LdDiagram *self, LdDiagramObject *object)
 | 
			
		||||
	uninstall_object (object, self);
 | 
			
		||||
 | 
			
		||||
	action_data = g_slice_new (ObjectActionData);
 | 
			
		||||
	action_data->self = g_object_ref (self);
 | 
			
		||||
	action_data->self = self;
 | 
			
		||||
	g_object_add_weak_pointer (G_OBJECT (self), &action_data->self);
 | 
			
		||||
	action_data->object = g_object_ref (object);
 | 
			
		||||
	action_data->pos = pos;
 | 
			
		||||
 | 
			
		||||
@@ -1024,13 +1032,15 @@ ld_diagram_select (LdDiagram *self, LdDiagramObject *object)
 | 
			
		||||
void
 | 
			
		||||
ld_diagram_unselect (LdDiagram *self, LdDiagramObject *object)
 | 
			
		||||
{
 | 
			
		||||
	GList *link;
 | 
			
		||||
 | 
			
		||||
	g_return_if_fail (LD_IS_DIAGRAM (self));
 | 
			
		||||
	g_return_if_fail (LD_IS_DIAGRAM_OBJECT (object));
 | 
			
		||||
 | 
			
		||||
	if (!g_list_find (self->priv->selection, object))
 | 
			
		||||
	if (!(link = g_list_find (self->priv->selection, object)))
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	self->priv->selection = g_list_remove (self->priv->selection, object);
 | 
			
		||||
	self->priv->selection = g_list_delete_link (self->priv->selection, link);
 | 
			
		||||
	g_object_unref (object);
 | 
			
		||||
 | 
			
		||||
	g_signal_emit (self,
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-diagram.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -15,16 +15,15 @@ G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define LD_TYPE_DIAGRAM (ld_diagram_get_type ())
 | 
			
		||||
#define LD_DIAGRAM(obj) (G_TYPE_CHECK_INSTANCE_CAST \
 | 
			
		||||
	((obj), LD_TYPE_DIAGRAM, LdDiagram))
 | 
			
		||||
#define LD_DIAGRAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
 | 
			
		||||
	((klass), LD_TYPE_DIAGRAM, LdDiagramClass))
 | 
			
		||||
#define LD_IS_DIAGRAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((obj), LD_TYPE_DIAGRAM))
 | 
			
		||||
#define LD_IS_DIAGRAM_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((klass), LD_TYPE_DIAGRAM))
 | 
			
		||||
#define LD_DIAGRAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
 | 
			
		||||
	((obj), LD_DIAGRAM, LdDiagramClass))
 | 
			
		||||
#define LD_DIAGRAM(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_DIAGRAM, LdDiagram))
 | 
			
		||||
#define LD_DIAGRAM_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_DIAGRAM, LdDiagramClass))
 | 
			
		||||
#define LD_IS_DIAGRAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_DIAGRAM))
 | 
			
		||||
#define LD_IS_DIAGRAM_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_DIAGRAM))
 | 
			
		||||
#define LD_DIAGRAM_GET_CLASS(obj) \
 | 
			
		||||
	(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_DIAGRAM, LdDiagramClass))
 | 
			
		||||
 | 
			
		||||
typedef struct _LdDiagram LdDiagram;
 | 
			
		||||
typedef struct _LdDiagramClass LdDiagramClass;
 | 
			
		||||
@@ -114,4 +113,3 @@ void ld_diagram_unselect_all (LdDiagram *self);
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_DIAGRAM_H__ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,776 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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
 | 
			
		||||
{
 | 
			
		||||
	CANVAS_HANDLER_EXPOSE,
 | 
			
		||||
	CANVAS_HANDLER_MOTION_NOTIFY,
 | 
			
		||||
	CANVAS_HANDLER_BUTTON_PRESS,
 | 
			
		||||
	CANVAS_HANDLER_BUTTON_RELEASE,
 | 
			
		||||
	CANVAS_HANDLER_COUNT
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * LdLibraryToolbarPrivate:
 | 
			
		||||
 * @library: a library object assigned to this canvas as a model.
 | 
			
		||||
 * @canvas: a canvas object for showing symbol menus.
 | 
			
		||||
 * @canvas_handlers: signal handlers that hook the canvas.
 | 
			
		||||
 * @symbol_menu: data related to menus.
 | 
			
		||||
 */
 | 
			
		||||
struct _LdLibraryToolbarPrivate
 | 
			
		||||
{
 | 
			
		||||
	LdLibrary *library;
 | 
			
		||||
	LdCanvas *canvas;
 | 
			
		||||
	gulong canvas_handlers[CANVAS_HANDLER_COUNT];
 | 
			
		||||
	SymbolMenuData symbol_menu;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum
 | 
			
		||||
{
 | 
			
		||||
	PROP_0,
 | 
			
		||||
	PROP_LIBRARY,
 | 
			
		||||
	PROP_CANVAS
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
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_canvas_handlers (LdLibraryToolbar *self);
 | 
			
		||||
static inline void unblock_canvas_handlers (LdLibraryToolbar *self);
 | 
			
		||||
static inline void disconnect_canvas_handlers (LdLibraryToolbar *self);
 | 
			
		||||
static gboolean on_canvas_exposed (GtkWidget *widget,
 | 
			
		||||
	GdkEventExpose *event, gpointer user_data);
 | 
			
		||||
static gboolean on_canvas_motion_notify (GtkWidget *widget,
 | 
			
		||||
	GdkEventMotion *event, gpointer user_data);
 | 
			
		||||
static gboolean on_canvas_button_press (GtkWidget *widget,
 | 
			
		||||
	GdkEventButton *event, gpointer user_data);
 | 
			
		||||
static gboolean on_canvas_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 canvas retrieves symbols from.
 | 
			
		||||
 */
 | 
			
		||||
	pspec = g_param_spec_object ("library", "Library",
 | 
			
		||||
		"The library that this canvas retrieves symbols from.",
 | 
			
		||||
		LD_TYPE_LIBRARY, G_PARAM_READWRITE);
 | 
			
		||||
	g_object_class_install_property (object_class, PROP_LIBRARY, pspec);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * LdLibraryToolbar:canvas:
 | 
			
		||||
 *
 | 
			
		||||
 * The #LdCanvas misused for showing symbol menus.
 | 
			
		||||
 */
 | 
			
		||||
	pspec = g_param_spec_object ("canvas", "Canvas",
 | 
			
		||||
		"The canvas misused for showing symbol menus.",
 | 
			
		||||
		LD_TYPE_CANVAS, G_PARAM_READWRITE);
 | 
			
		||||
	g_object_class_install_property (object_class, PROP_CANVAS, 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_canvas (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_CANVAS:
 | 
			
		||||
		g_value_set_object (value, ld_library_toolbar_get_canvas (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_CANVAS:
 | 
			
		||||
		ld_library_toolbar_set_canvas (self,
 | 
			
		||||
			LD_CANVAS (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 #LdLibrary 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.
 | 
			
		||||
 *
 | 
			
		||||
 * Get the #LdLibrary object assigned to this toolbar.
 | 
			
		||||
 * The reference count on the library is not incremented.
 | 
			
		||||
 */
 | 
			
		||||
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_canvas:
 | 
			
		||||
 * @self: an #LdLibraryToolbar object.
 | 
			
		||||
 * @canvas: (allow-none): the #LdCanvas to be assigned to the toolbar.
 | 
			
		||||
 *
 | 
			
		||||
 * Assign an #LdCanvas object to the toolbar.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
ld_library_toolbar_set_canvas (LdLibraryToolbar *self, LdCanvas *canvas)
 | 
			
		||||
{
 | 
			
		||||
	g_return_if_fail (LD_IS_LIBRARY_TOOLBAR (self));
 | 
			
		||||
	g_return_if_fail (LD_IS_CANVAS (canvas) || canvas == NULL);
 | 
			
		||||
 | 
			
		||||
	if (self->priv->canvas)
 | 
			
		||||
	{
 | 
			
		||||
		disconnect_canvas_handlers (self);
 | 
			
		||||
		g_object_unref (self->priv->canvas);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	self->priv->canvas = canvas;
 | 
			
		||||
 | 
			
		||||
	if (canvas)
 | 
			
		||||
	{
 | 
			
		||||
		self->priv->canvas_handlers[CANVAS_HANDLER_EXPOSE]
 | 
			
		||||
			= g_signal_connect (canvas, "expose-event",
 | 
			
		||||
			G_CALLBACK (on_canvas_exposed), self);
 | 
			
		||||
		self->priv->canvas_handlers[CANVAS_HANDLER_MOTION_NOTIFY]
 | 
			
		||||
			= g_signal_connect (canvas, "motion-notify-event",
 | 
			
		||||
			G_CALLBACK (on_canvas_motion_notify), self);
 | 
			
		||||
		self->priv->canvas_handlers[CANVAS_HANDLER_BUTTON_PRESS]
 | 
			
		||||
			= g_signal_connect (canvas, "button-press-event",
 | 
			
		||||
			G_CALLBACK (on_canvas_button_press), self);
 | 
			
		||||
		self->priv->canvas_handlers[CANVAS_HANDLER_BUTTON_RELEASE]
 | 
			
		||||
			= g_signal_connect (canvas, "button-release-event",
 | 
			
		||||
			G_CALLBACK (on_canvas_button_release), self);
 | 
			
		||||
 | 
			
		||||
		block_canvas_handlers (self);
 | 
			
		||||
		g_object_ref (canvas);
 | 
			
		||||
	}
 | 
			
		||||
	g_object_notify (G_OBJECT (self), "canvas");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ld_library_toolbar_get_canvas:
 | 
			
		||||
 * @self: an #LdLibraryToolbar object.
 | 
			
		||||
 *
 | 
			
		||||
 * Get the #LdLibrary object assigned to this toolbar.
 | 
			
		||||
 * The reference count on the canvas is not incremented.
 | 
			
		||||
 */
 | 
			
		||||
LdCanvas *
 | 
			
		||||
ld_library_toolbar_get_canvas (LdLibraryToolbar *self)
 | 
			
		||||
{
 | 
			
		||||
	g_return_val_if_fail (LD_IS_LIBRARY_TOOLBAR (self), NULL);
 | 
			
		||||
	return self->priv->canvas;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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 canvas. */
 | 
			
		||||
	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->canvas),
 | 
			
		||||
		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_canvas_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->canvas));
 | 
			
		||||
	}
 | 
			
		||||
	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->canvas), 0, 0, &x, &y));
 | 
			
		||||
 | 
			
		||||
		data->menu_y = y;
 | 
			
		||||
		data->menu_height = GTK_WIDGET (toggle_button)->allocation.height;
 | 
			
		||||
 | 
			
		||||
		unblock_canvas_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;
 | 
			
		||||
			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->canvas));
 | 
			
		||||
	}
 | 
			
		||||
	redraw_symbol_menu (self);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define DEFINE_CANVAS_HANDLER_FUNC(name) \
 | 
			
		||||
static inline void \
 | 
			
		||||
name ## _canvas_handlers (LdLibraryToolbar *self) \
 | 
			
		||||
{ \
 | 
			
		||||
	gint i; \
 | 
			
		||||
	g_return_if_fail (LD_IS_CANVAS (self->priv->canvas)); \
 | 
			
		||||
	for (i = 0; i < CANVAS_HANDLER_COUNT; i++) \
 | 
			
		||||
		g_signal_handler_ ## name (self->priv->canvas, \
 | 
			
		||||
			self->priv->canvas_handlers[i]); \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFINE_CANVAS_HANDLER_FUNC (block)
 | 
			
		||||
DEFINE_CANVAS_HANDLER_FUNC (unblock)
 | 
			
		||||
DEFINE_CANVAS_HANDLER_FUNC (disconnect)
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
on_canvas_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;
 | 
			
		||||
 | 
			
		||||
		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, data->menu_y, 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_canvas_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_canvas_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_canvas_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_canvas_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_canvas_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;
 | 
			
		||||
}
 | 
			
		||||
@@ -1,69 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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_canvas (LdLibraryToolbar *self,
 | 
			
		||||
	LdCanvas *canvas);
 | 
			
		||||
LdCanvas *ld_library_toolbar_get_canvas (LdLibraryToolbar *self);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_LIBRARY_TOOLBAR_H__ */
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-library.c
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011, 2012 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -17,28 +17,30 @@
 | 
			
		||||
/**
 | 
			
		||||
 * SECTION:ld-library
 | 
			
		||||
 * @short_description: A symbol library
 | 
			
		||||
 * @see_also: #LdSymbol, #LdSymbolCategory
 | 
			
		||||
 * @see_also: #LdSymbol, #LdCategory
 | 
			
		||||
 *
 | 
			
		||||
 * #LdLibrary is used for loading symbols from their files.
 | 
			
		||||
 * #LdLibrary is used for loading symbols from their files.  The library object
 | 
			
		||||
 * itself is a container for categories, which in turn contain other
 | 
			
		||||
 * subcategories and the actual symbols.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * LdLibraryPrivate:
 | 
			
		||||
 * @lua: state of the scripting language.
 | 
			
		||||
 * @children: child objects of the library.
 | 
			
		||||
 * @children: categories in the library.
 | 
			
		||||
 */
 | 
			
		||||
struct _LdLibraryPrivate
 | 
			
		||||
{
 | 
			
		||||
	LdLua *lua;
 | 
			
		||||
	GSList *children;
 | 
			
		||||
	LdCategory *root;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static void ld_library_finalize (GObject *gobject);
 | 
			
		||||
 | 
			
		||||
static LdSymbolCategory *load_category (LdLibrary *self,
 | 
			
		||||
static LdCategory *load_category (LdLibrary *self,
 | 
			
		||||
	const gchar *path, const gchar *name);
 | 
			
		||||
static gboolean load_category_cb (const gchar *base,
 | 
			
		||||
	const gchar *filename, gpointer userdata);
 | 
			
		||||
	const gchar *path, gpointer userdata);
 | 
			
		||||
static void load_category_symbol_cb (LdSymbol *symbol, gpointer user_data);
 | 
			
		||||
 | 
			
		||||
static gchar *read_human_name_from_file (const gchar *filename);
 | 
			
		||||
@@ -46,11 +48,9 @@ static gchar *read_human_name_from_file (const gchar *filename);
 | 
			
		||||
static gboolean foreach_dir (const gchar *path,
 | 
			
		||||
	gboolean (*callback) (const gchar *, const gchar *, gpointer),
 | 
			
		||||
	gpointer userdata, GError **error);
 | 
			
		||||
static gboolean ld_library_load_cb
 | 
			
		||||
	(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
 | 
			
		||||
ld_library_class_init (LdLibraryClass *klass)
 | 
			
		||||
@@ -81,7 +81,7 @@ ld_library_init (LdLibrary *self)
 | 
			
		||||
		(self, LD_TYPE_LIBRARY, LdLibraryPrivate);
 | 
			
		||||
 | 
			
		||||
	self->priv->lua = ld_lua_new ();
 | 
			
		||||
	self->priv->children = NULL;
 | 
			
		||||
	self->priv->root = ld_category_new (LD_LIBRARY_IDENTIFIER_SEPARATOR, "/");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
@@ -92,9 +92,7 @@ ld_library_finalize (GObject *gobject)
 | 
			
		||||
	self = LD_LIBRARY (gobject);
 | 
			
		||||
 | 
			
		||||
	g_object_unref (self->priv->lua);
 | 
			
		||||
 | 
			
		||||
	g_slist_foreach (self->priv->children, (GFunc) g_object_unref, NULL);
 | 
			
		||||
	g_slist_free (self->priv->children);
 | 
			
		||||
	g_object_unref (self->priv->root);
 | 
			
		||||
 | 
			
		||||
	/* Chain up to the parent class. */
 | 
			
		||||
	G_OBJECT_CLASS (ld_library_parent_class)->finalize (gobject);
 | 
			
		||||
@@ -152,7 +150,9 @@ foreach_dir (const gchar *path,
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
	LdLibrary *self;
 | 
			
		||||
	LdSymbolCategory *cat;
 | 
			
		||||
	LdCategory *cat;
 | 
			
		||||
	guint changed : 1;
 | 
			
		||||
	guint load_symbols : 1;
 | 
			
		||||
}
 | 
			
		||||
LoadCategoryData;
 | 
			
		||||
 | 
			
		||||
@@ -164,12 +164,10 @@ LoadCategoryData;
 | 
			
		||||
 *
 | 
			
		||||
 * Loads a category into the library.
 | 
			
		||||
 */
 | 
			
		||||
static LdSymbolCategory *
 | 
			
		||||
static LdCategory *
 | 
			
		||||
load_category (LdLibrary *self, const gchar *path, const gchar *name)
 | 
			
		||||
{
 | 
			
		||||
	LdSymbolCategory *cat;
 | 
			
		||||
	gchar *icon_file, *category_file;
 | 
			
		||||
	gchar *human_name;
 | 
			
		||||
	gchar *category_file, *human_name;
 | 
			
		||||
	LoadCategoryData data;
 | 
			
		||||
 | 
			
		||||
	g_return_val_if_fail (LD_IS_LIBRARY (self), NULL);
 | 
			
		||||
@@ -177,57 +175,59 @@ load_category (LdLibrary *self, const gchar *path, const gchar *name)
 | 
			
		||||
	g_return_val_if_fail (name != NULL, NULL);
 | 
			
		||||
 | 
			
		||||
	if (!g_file_test (path, G_FILE_TEST_IS_DIR))
 | 
			
		||||
		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;
 | 
			
		||||
	}
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	category_file = g_build_filename (path, "category.json", NULL);
 | 
			
		||||
	human_name = read_human_name_from_file (category_file);
 | 
			
		||||
	if (!human_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.cat = cat;
 | 
			
		||||
	data.cat = ld_category_new (name, human_name);
 | 
			
		||||
	data.load_symbols = TRUE;
 | 
			
		||||
	data.changed = FALSE;
 | 
			
		||||
	foreach_dir (path, load_category_cb, &data, NULL);
 | 
			
		||||
 | 
			
		||||
	g_free (human_name);
 | 
			
		||||
	g_free (category_file);
 | 
			
		||||
	g_free (icon_file);
 | 
			
		||||
	return cat;
 | 
			
		||||
 | 
			
		||||
load_category_fail_2:
 | 
			
		||||
	g_free (icon_file);
 | 
			
		||||
load_category_fail_1:
 | 
			
		||||
	return NULL;
 | 
			
		||||
	return data.cat;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * load_category_cb:
 | 
			
		||||
 *
 | 
			
		||||
 * Load script files from a directory into a symbol category.
 | 
			
		||||
 * Load contents of a directory into a symbol category.
 | 
			
		||||
 */
 | 
			
		||||
static gboolean
 | 
			
		||||
load_category_cb (const gchar *base, const gchar *filename, gpointer userdata)
 | 
			
		||||
load_category_cb (const gchar *base, const gchar *path, gpointer userdata)
 | 
			
		||||
{
 | 
			
		||||
	LoadCategoryData *data;
 | 
			
		||||
 | 
			
		||||
	g_return_val_if_fail (base != NULL, FALSE);
 | 
			
		||||
	g_return_val_if_fail (filename != NULL, FALSE);
 | 
			
		||||
	g_return_val_if_fail (path != NULL, FALSE);
 | 
			
		||||
	g_return_val_if_fail (userdata != NULL, FALSE);
 | 
			
		||||
 | 
			
		||||
	data = (LoadCategoryData *) userdata;
 | 
			
		||||
 | 
			
		||||
	if (ld_lua_check_file (data->self->priv->lua, filename))
 | 
			
		||||
		ld_lua_load_file (data->self->priv->lua, filename,
 | 
			
		||||
	if (g_file_test (path, G_FILE_TEST_IS_DIR))
 | 
			
		||||
	{
 | 
			
		||||
		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);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data->changed = TRUE;
 | 
			
		||||
	return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -239,30 +239,13 @@ load_category_cb (const gchar *base, const gchar *filename, gpointer userdata)
 | 
			
		||||
static void
 | 
			
		||||
load_category_symbol_cb (LdSymbol *symbol, gpointer user_data)
 | 
			
		||||
{
 | 
			
		||||
	const gchar *name;
 | 
			
		||||
	LdSymbolCategory *cat;
 | 
			
		||||
	const GSList *children, *iter;
 | 
			
		||||
	LdCategory *cat;
 | 
			
		||||
 | 
			
		||||
	g_return_if_fail (LD_IS_SYMBOL (symbol));
 | 
			
		||||
	g_return_if_fail (LD_IS_SYMBOL_CATEGORY (user_data));
 | 
			
		||||
	g_return_if_fail (LD_IS_CATEGORY (user_data));
 | 
			
		||||
 | 
			
		||||
	cat = LD_SYMBOL_CATEGORY (user_data);
 | 
			
		||||
	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);
 | 
			
		||||
	cat = LD_CATEGORY (user_data);
 | 
			
		||||
	ld_category_insert_symbol (cat, symbol, -1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@@ -323,18 +306,6 @@ read_human_name_from_file_end:
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * LibraryLoadData:
 | 
			
		||||
 *
 | 
			
		||||
 * Data shared between ld_library_load() and ld_library_load_cb().
 | 
			
		||||
 */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
	LdLibrary *self;
 | 
			
		||||
	gboolean changed;
 | 
			
		||||
}
 | 
			
		||||
LibraryLoadData;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ld_library_load:
 | 
			
		||||
 * @self: an #LdLibrary object.
 | 
			
		||||
@@ -345,46 +316,34 @@ LibraryLoadData;
 | 
			
		||||
gboolean
 | 
			
		||||
ld_library_load (LdLibrary *self, const gchar *directory)
 | 
			
		||||
{
 | 
			
		||||
	LibraryLoadData data;
 | 
			
		||||
	LoadCategoryData data;
 | 
			
		||||
 | 
			
		||||
	g_return_val_if_fail (LD_IS_LIBRARY (self), FALSE);
 | 
			
		||||
	g_return_val_if_fail (directory != NULL, FALSE);
 | 
			
		||||
 | 
			
		||||
	/* Almost like load_category(). */
 | 
			
		||||
	data.self = self;
 | 
			
		||||
	data.cat = self->priv->root;
 | 
			
		||||
	data.load_symbols = FALSE;
 | 
			
		||||
	data.changed = FALSE;
 | 
			
		||||
	foreach_dir (directory, ld_library_load_cb, &data, NULL);
 | 
			
		||||
	foreach_dir (directory, load_category_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)
 | 
			
		||||
		g_signal_emit (self, LD_LIBRARY_GET_CLASS (self)->changed_signal, 0);
 | 
			
		||||
 | 
			
		||||
	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:
 | 
			
		||||
 * @self: an #LdLibrary object.
 | 
			
		||||
@@ -394,12 +353,12 @@ ld_library_load_cb (const gchar *base, const gchar *filename, gpointer userdata)
 | 
			
		||||
 *
 | 
			
		||||
 * Return value: a symbol object if found, %NULL otherwise.
 | 
			
		||||
 */
 | 
			
		||||
/* XXX: With this level of indentation, this function is really ugly. */
 | 
			
		||||
LdSymbol *
 | 
			
		||||
ld_library_find_symbol (LdLibrary *self, const gchar *identifier)
 | 
			
		||||
{
 | 
			
		||||
	gchar **id_el_start, **id_el;
 | 
			
		||||
	const GSList *list, *list_el;
 | 
			
		||||
	LdCategory *cat;
 | 
			
		||||
 | 
			
		||||
	g_return_val_if_fail (LD_IS_LIBRARY (self), NULL);
 | 
			
		||||
	g_return_val_if_fail (identifier != NULL, NULL);
 | 
			
		||||
@@ -408,117 +367,63 @@ ld_library_find_symbol (LdLibrary *self, const gchar *identifier)
 | 
			
		||||
	if (!id_el_start)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	list = ld_library_get_children (self);
 | 
			
		||||
	for (id_el = id_el_start; id_el[0]; id_el++)
 | 
			
		||||
	/* We need at least one category name plus the symbol name. */
 | 
			
		||||
	id_el = id_el_start;
 | 
			
		||||
	if (!id_el[0] || !id_el[1])
 | 
			
		||||
		goto ld_library_find_symbol_error;
 | 
			
		||||
 | 
			
		||||
	/* Find the category where the symbol is in. */
 | 
			
		||||
	cat = self->priv->root;
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		LdSymbolCategory *cat;
 | 
			
		||||
		LdSymbol *symbol;
 | 
			
		||||
		gboolean found = FALSE;
 | 
			
		||||
 | 
			
		||||
		list = ld_category_get_children (cat);
 | 
			
		||||
		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_CATEGORY (list_el->data);
 | 
			
		||||
			if (!strcmp (*id_el, ld_category_get_name (cat)))
 | 
			
		||||
			{
 | 
			
		||||
				cat = LD_SYMBOL_CATEGORY (list_el->data);
 | 
			
		||||
				if (strcmp (id_el[0], ld_symbol_category_get_name (cat)))
 | 
			
		||||
					continue;
 | 
			
		||||
 | 
			
		||||
				list = ld_symbol_category_get_children (cat);
 | 
			
		||||
				found = TRUE;
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
			/* If the current identifier element is a symbol (last)
 | 
			
		||||
			 * and this list element is a symbol.
 | 
			
		||||
			 */
 | 
			
		||||
			else if (!id_el[1] && LD_IS_SYMBOL (list_el->data))
 | 
			
		||||
			{
 | 
			
		||||
				symbol = LD_SYMBOL (list_el->data);
 | 
			
		||||
				if (strcmp (id_el[0], ld_symbol_get_name (symbol)))
 | 
			
		||||
					continue;
 | 
			
		||||
 | 
			
		||||
				g_strfreev (id_el_start);
 | 
			
		||||
				return symbol;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!found)
 | 
			
		||||
			goto ld_library_find_symbol_error;
 | 
			
		||||
 | 
			
		||||
		if (!(id_el++)[2])
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* And then the actual symbol. */
 | 
			
		||||
	list = ld_category_get_symbols (cat);
 | 
			
		||||
	for (list_el = list; list_el; list_el = g_slist_next (list_el))
 | 
			
		||||
	{
 | 
			
		||||
		LdSymbol *symbol;
 | 
			
		||||
 | 
			
		||||
		symbol = LD_SYMBOL (list_el->data);
 | 
			
		||||
		if (!strcmp (*id_el, ld_symbol_get_name (symbol)))
 | 
			
		||||
		{
 | 
			
		||||
			g_strfreev (id_el_start);
 | 
			
		||||
			return symbol;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
ld_library_find_symbol_error:
 | 
			
		||||
	g_strfreev (id_el_start);
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ld_library_clear:
 | 
			
		||||
 * ld_library_get_root:
 | 
			
		||||
 * @self: an #LdLibrary object.
 | 
			
		||||
 *
 | 
			
		||||
 * Clear all the contents.
 | 
			
		||||
 * Return value: (transfer none): the root category. Do not modify.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
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)
 | 
			
		||||
LdCategory *
 | 
			
		||||
ld_library_get_root (LdLibrary *self)
 | 
			
		||||
{
 | 
			
		||||
	g_return_val_if_fail (LD_IS_LIBRARY (self), NULL);
 | 
			
		||||
	return self->priv->children;
 | 
			
		||||
	return self->priv->root;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-library.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2012 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -15,16 +15,15 @@ G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define LD_TYPE_LIBRARY (ld_library_get_type ())
 | 
			
		||||
#define LD_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_CAST \
 | 
			
		||||
	((obj), LD_TYPE_LIBRARY, LdLibrary))
 | 
			
		||||
#define LD_LIBRARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
 | 
			
		||||
	((klass), LD_TYPE_LIBRARY, LdLibraryClass))
 | 
			
		||||
#define LD_IS_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((obj), LD_TYPE_LIBRARY))
 | 
			
		||||
#define LD_IS_LIBRARY_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((klass), LD_TYPE_LIBRARY))
 | 
			
		||||
#define LD_LIBRARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
 | 
			
		||||
	((obj), LD_LIBRARY, LdLibraryClass))
 | 
			
		||||
#define LD_LIBRARY(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_LIBRARY, LdLibrary))
 | 
			
		||||
#define LD_LIBRARY_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_LIBRARY, LdLibraryClass))
 | 
			
		||||
#define LD_IS_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_LIBRARY))
 | 
			
		||||
#define LD_IS_LIBRARY_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_LIBRARY))
 | 
			
		||||
#define LD_LIBRARY_GET_CLASS(obj) \
 | 
			
		||||
	(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_LIBRARY, LdLibraryClass))
 | 
			
		||||
 | 
			
		||||
typedef struct _LdLibrary LdLibrary;
 | 
			
		||||
typedef struct _LdLibraryPrivate LdLibraryPrivate;
 | 
			
		||||
@@ -60,14 +59,9 @@ GType ld_library_get_type (void) G_GNUC_CONST;
 | 
			
		||||
LdLibrary *ld_library_new (void);
 | 
			
		||||
gboolean ld_library_load (LdLibrary *self, const gchar *directory);
 | 
			
		||||
LdSymbol *ld_library_find_symbol (LdLibrary *self, const gchar *identifier);
 | 
			
		||||
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);
 | 
			
		||||
LdCategory *ld_library_get_root (LdLibrary *self);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_LIBRARY_H__ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-lua-private.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010. All rights reserved.
 | 
			
		||||
 * Copyright 2010 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -23,4 +23,3 @@ void ld_lua_private_draw (LdLua *self, LdLuaSymbol *symbol, cairo_t *cr);
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_LUA_PRIVATE_H__ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-lua-symbol-private.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -37,4 +37,3 @@ struct _LdLuaSymbolPrivate
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_LUA_SYMBOL_PRIVATE_H__ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-lua-symbol.c
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * 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);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
G_DEFINE_TYPE (LdLuaSymbol, ld_lua_symbol, LD_TYPE_SYMBOL);
 | 
			
		||||
G_DEFINE_TYPE (LdLuaSymbol, ld_lua_symbol, LD_TYPE_SYMBOL)
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
ld_lua_symbol_class_init (LdLuaSymbolClass *klass)
 | 
			
		||||
@@ -135,4 +135,3 @@ ld_lua_symbol_real_draw (LdSymbol *symbol, cairo_t *cr)
 | 
			
		||||
	ld_lua_private_draw (self->priv->lua, self, cr);
 | 
			
		||||
	cairo_restore (cr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-lua-symbol.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010. All rights reserved.
 | 
			
		||||
 * Copyright 2010 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * 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_LUA_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST \
 | 
			
		||||
	((obj), LD_TYPE_LUA_SYMBOL, LdLuaSymbol))
 | 
			
		||||
#define LD_LUA_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
 | 
			
		||||
	((klass), LD_TYPE_LUA_SYMBOL, LdLuaSymbolClass))
 | 
			
		||||
#define LD_IS_LUA_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((obj), LD_TYPE_LUA_SYMBOL))
 | 
			
		||||
#define LD_IS_LUA_SYMBOL_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((klass), LD_TYPE_LUA_SYMBOL))
 | 
			
		||||
#define LD_LUA_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
 | 
			
		||||
	((obj), LD_LUA_SYMBOL, LdLuaSymbolClass))
 | 
			
		||||
#define LD_LUA_SYMBOL(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_LUA_SYMBOL, LdLuaSymbol))
 | 
			
		||||
#define LD_LUA_SYMBOL_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_LUA_SYMBOL, LdLuaSymbolClass))
 | 
			
		||||
#define LD_IS_LUA_SYMBOL(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_LUA_SYMBOL))
 | 
			
		||||
#define LD_IS_LUA_SYMBOL_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_LUA_SYMBOL))
 | 
			
		||||
#define LD_LUA_SYMBOL_GET_CLASS(obj) \
 | 
			
		||||
	(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_LUA_SYMBOL, LdLuaSymbolClass))
 | 
			
		||||
 | 
			
		||||
typedef struct _LdLuaSymbol LdLuaSymbol;
 | 
			
		||||
typedef struct _LdLuaSymbolPrivate LdLuaSymbolPrivate;
 | 
			
		||||
@@ -57,4 +57,3 @@ GType ld_lua_symbol_get_type (void) G_GNUC_CONST;
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_LUA_SYMBOL_H__ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-lua.c
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011, 2012 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -44,9 +44,10 @@ struct _LdLuaPrivate
 | 
			
		||||
 *   -> The rendering function
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define LD_LUA_LIBRARY_NAME "logdiag"
 | 
			
		||||
#define LD_LUA_DATA_INDEX LD_LUA_LIBRARY_NAME "_data"
 | 
			
		||||
#define LD_LUA_SYMBOLS_INDEX LD_LUA_LIBRARY_NAME "_symbols"
 | 
			
		||||
#define LD_LUA_LIBRARY_NAME   "logdiag"
 | 
			
		||||
#define LD_LUA_DATA_INDEX     LD_LUA_LIBRARY_NAME "_data"
 | 
			
		||||
#define LD_LUA_SYMBOLS_INDEX  LD_LUA_LIBRARY_NAME "_symbols"
 | 
			
		||||
#define LD_LUA_META_INDEX     LD_LUA_LIBRARY_NAME "_meta"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * LdLuaData:
 | 
			
		||||
@@ -88,12 +89,14 @@ static gboolean read_symbol_area (lua_State *L, int index, LdRectangle *area);
 | 
			
		||||
static gboolean read_terminals (lua_State *L, int index,
 | 
			
		||||
	LdPointArray **terminals);
 | 
			
		||||
 | 
			
		||||
static void push_cairo_object (lua_State *L, LdLuaDrawData *draw_data);
 | 
			
		||||
static gdouble get_cairo_scale (cairo_t *cr);
 | 
			
		||||
static int ld_lua_cairo_save (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_restore (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_get_line_width (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_set_line_width (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_translate (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_scale (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_rotate (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_move_to (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_line_to (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_curve_to (lua_State *L);
 | 
			
		||||
@@ -108,6 +111,7 @@ static int ld_lua_cairo_fill (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_fill_preserve (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_clip (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_clip_preserve (lua_State *L);
 | 
			
		||||
static int ld_lua_cairo_show_text (lua_State *L);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static luaL_Reg ld_lua_logdiag_lib[] =
 | 
			
		||||
@@ -122,6 +126,9 @@ static luaL_Reg ld_lua_cairo_table[] =
 | 
			
		||||
	{"restore", ld_lua_cairo_restore},
 | 
			
		||||
	{"get_line_width", ld_lua_cairo_get_line_width},
 | 
			
		||||
	{"set_line_width", ld_lua_cairo_set_line_width},
 | 
			
		||||
	{"translate", ld_lua_cairo_translate},
 | 
			
		||||
	{"scale", ld_lua_cairo_scale},
 | 
			
		||||
	{"rotate", ld_lua_cairo_rotate},
 | 
			
		||||
	{"move_to", ld_lua_cairo_move_to},
 | 
			
		||||
	{"line_to", ld_lua_cairo_line_to},
 | 
			
		||||
	{"curve_to", ld_lua_cairo_curve_to},
 | 
			
		||||
@@ -136,13 +143,14 @@ static luaL_Reg ld_lua_cairo_table[] =
 | 
			
		||||
	{"fill_preserve", ld_lua_cairo_fill_preserve},
 | 
			
		||||
	{"clip", ld_lua_cairo_clip},
 | 
			
		||||
	{"clip_preserve", ld_lua_cairo_clip_preserve},
 | 
			
		||||
	{"show_text", ld_lua_cairo_show_text},
 | 
			
		||||
	{NULL, NULL}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* ===== Generic =========================================================== */
 | 
			
		||||
 | 
			
		||||
G_DEFINE_TYPE (LdLua, ld_lua, G_TYPE_OBJECT);
 | 
			
		||||
G_DEFINE_TYPE (LdLua, ld_lua, G_TYPE_OBJECT)
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
ld_lua_class_init (LdLuaClass *klass)
 | 
			
		||||
@@ -155,35 +163,49 @@ ld_lua_class_init (LdLuaClass *klass)
 | 
			
		||||
	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
 | 
			
		||||
ld_lua_init (LdLua *self)
 | 
			
		||||
{
 | 
			
		||||
	lua_State *L;
 | 
			
		||||
	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);
 | 
			
		||||
	g_return_if_fail (L != NULL);
 | 
			
		||||
 | 
			
		||||
	/* TODO: lua_atpanic () */
 | 
			
		||||
	/* XXX: Might not be a bad idea to use lua_atpanic(). */
 | 
			
		||||
 | 
			
		||||
	/* Load some safe libraries. */
 | 
			
		||||
	lua_pushcfunction (L, luaopen_string);
 | 
			
		||||
	lua_call (L, 0, 0);
 | 
			
		||||
 | 
			
		||||
	lua_pushcfunction (L, luaopen_table);
 | 
			
		||||
	lua_call (L, 0, 0);
 | 
			
		||||
 | 
			
		||||
	lua_pushcfunction (L, luaopen_math);
 | 
			
		||||
	lua_call (L, 0, 0);
 | 
			
		||||
	luaL_requiref (L, "string", luaopen_string, TRUE);
 | 
			
		||||
	luaL_requiref (L, "table",  luaopen_table,  TRUE);
 | 
			
		||||
	luaL_requiref (L, "math",   luaopen_math,   TRUE);
 | 
			
		||||
	lua_pop (L, 3);
 | 
			
		||||
 | 
			
		||||
	/* Load the application library. */
 | 
			
		||||
	luaL_register (L, LD_LUA_LIBRARY_NAME, ld_lua_logdiag_lib);
 | 
			
		||||
	luaL_newlib (L, ld_lua_logdiag_lib);
 | 
			
		||||
	lua_setglobal (L, LD_LUA_LIBRARY_NAME);
 | 
			
		||||
 | 
			
		||||
	/* Store user data to the registry. */
 | 
			
		||||
	ud = lua_newuserdata (L, sizeof (LdLuaData));
 | 
			
		||||
	ud = lua_newuserdata (L, sizeof *ud);
 | 
			
		||||
	ud->self = self;
 | 
			
		||||
	ud->load_callback = NULL;
 | 
			
		||||
	ud->load_user_data = NULL;
 | 
			
		||||
@@ -193,6 +215,8 @@ ld_lua_init (LdLua *self)
 | 
			
		||||
	/* Create an empty symbol table. */
 | 
			
		||||
	lua_newtable (L);
 | 
			
		||||
	lua_setfield (L, LUA_REGISTRYINDEX, LD_LUA_SYMBOLS_INDEX);
 | 
			
		||||
 | 
			
		||||
	push_cairo_metatable (L);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
@@ -270,7 +294,7 @@ ld_lua_load_file (LdLua *self, const gchar *filename,
 | 
			
		||||
	g_return_val_if_fail (filename != NULL, FALSE);
 | 
			
		||||
	g_return_val_if_fail (callback != NULL, FALSE);
 | 
			
		||||
 | 
			
		||||
	/* XXX: If something from the following fails, Lua will call exit(). */
 | 
			
		||||
	/* XXX: If something from the following fails, Lua will panic. */
 | 
			
		||||
	lua_getfield (self->priv->L, LUA_REGISTRYINDEX, LD_LUA_DATA_INDEX);
 | 
			
		||||
	ud = lua_touserdata (self->priv->L, -1);
 | 
			
		||||
	lua_pop (self->priv->L, 1);
 | 
			
		||||
@@ -323,7 +347,9 @@ ld_lua_private_draw (LdLua *self, LdLuaSymbol *symbol, cairo_t *cr)
 | 
			
		||||
	data.cr = cr;
 | 
			
		||||
	data.save_count = 0;
 | 
			
		||||
 | 
			
		||||
	if (lua_cpcall (self->priv->L, ld_lua_private_draw_cb, &data))
 | 
			
		||||
	lua_pushcfunction (self->priv->L, ld_lua_private_draw_cb);
 | 
			
		||||
	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));
 | 
			
		||||
		lua_pop (self->priv->L, 1);
 | 
			
		||||
@@ -336,7 +362,7 @@ ld_lua_private_draw (LdLua *self, LdLuaSymbol *symbol, cairo_t *cr)
 | 
			
		||||
static int
 | 
			
		||||
ld_lua_private_draw_cb (lua_State *L)
 | 
			
		||||
{
 | 
			
		||||
	LdLuaDrawData *data;
 | 
			
		||||
	LdLuaDrawData *data, *luadata;
 | 
			
		||||
 | 
			
		||||
	data = lua_touserdata (L, -1);
 | 
			
		||||
 | 
			
		||||
@@ -349,9 +375,28 @@ ld_lua_private_draw_cb (lua_State *L)
 | 
			
		||||
	lua_getfield (L, -1, "render");
 | 
			
		||||
	luaL_checktype (L, -1, LUA_TFUNCTION);
 | 
			
		||||
 | 
			
		||||
	/* Call the function do draw the symbol. */
 | 
			
		||||
	push_cairo_object (L, data);
 | 
			
		||||
	lua_pcall (L, 1, 0, 0);
 | 
			
		||||
	/* Create a Cairo wrapper object. */
 | 
			
		||||
	luadata = lua_newuserdata (L, sizeof *data);
 | 
			
		||||
	memcpy (luadata, data, sizeof *data);
 | 
			
		||||
	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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -368,7 +413,9 @@ ld_lua_private_unregister (LdLua *self, LdLuaSymbol *symbol)
 | 
			
		||||
	g_return_if_fail (LD_IS_LUA (self));
 | 
			
		||||
	g_return_if_fail (LD_IS_LUA_SYMBOL (symbol));
 | 
			
		||||
 | 
			
		||||
	if (lua_cpcall (self->priv->L, ld_lua_private_unregister_cb, symbol))
 | 
			
		||||
	lua_pushcfunction (self->priv->L, ld_lua_private_unregister_cb);
 | 
			
		||||
	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));
 | 
			
		||||
		lua_pop (self->priv->L, 1);
 | 
			
		||||
@@ -417,8 +464,7 @@ ld_lua_logdiag_register (lua_State *L)
 | 
			
		||||
		lua_insert (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);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
@@ -445,6 +491,7 @@ static int
 | 
			
		||||
process_registration (lua_State *L)
 | 
			
		||||
{
 | 
			
		||||
	LdLuaSymbol *symbol;
 | 
			
		||||
	const gchar *name;
 | 
			
		||||
	gchar *human_name;
 | 
			
		||||
 | 
			
		||||
	int i, type, types[] =
 | 
			
		||||
@@ -461,7 +508,10 @@ process_registration (lua_State *L)
 | 
			
		||||
				lua_typename (L, types[i]), lua_typename (L, type));
 | 
			
		||||
 | 
			
		||||
	symbol = LD_LUA_SYMBOL (lua_touserdata (L, lua_upvalueindex (1)));
 | 
			
		||||
	symbol->priv->name = g_strdup (lua_tostring (L, 1));
 | 
			
		||||
	name = 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);
 | 
			
		||||
	if (!human_name)
 | 
			
		||||
@@ -529,7 +579,7 @@ read_symbol_area (lua_State *L, int index, LdRectangle *area)
 | 
			
		||||
{
 | 
			
		||||
	lua_Number x1, x2, y1, y2;
 | 
			
		||||
 | 
			
		||||
	if (lua_objlen (L, index) != 4)
 | 
			
		||||
	if (lua_rawlen (L, index) != 4)
 | 
			
		||||
		return FALSE;
 | 
			
		||||
 | 
			
		||||
	lua_rawgeti (L, index, 1);
 | 
			
		||||
@@ -554,7 +604,7 @@ read_symbol_area (lua_State *L, int index, LdRectangle *area)
 | 
			
		||||
 | 
			
		||||
	area->x = MIN (x1, x2);
 | 
			
		||||
	area->y = MIN (y1, y2);
 | 
			
		||||
	area->width = ABS (x2 - x1);
 | 
			
		||||
	area->width  = ABS (x2 - x1);
 | 
			
		||||
	area->height = ABS (y2 - y1);
 | 
			
		||||
 | 
			
		||||
	lua_pop (L, 4);
 | 
			
		||||
@@ -577,7 +627,7 @@ read_terminals (lua_State *L, int index, LdPointArray **terminals)
 | 
			
		||||
	LdPointArray *points;
 | 
			
		||||
	size_t num_points;
 | 
			
		||||
 | 
			
		||||
	num_points = lua_objlen (L, index);
 | 
			
		||||
	num_points = lua_rawlen (L, index);
 | 
			
		||||
	points = ld_point_array_sized_new (num_points);
 | 
			
		||||
 | 
			
		||||
	lua_pushnil (L);
 | 
			
		||||
@@ -585,7 +635,7 @@ read_terminals (lua_State *L, int index, LdPointArray **terminals)
 | 
			
		||||
	{
 | 
			
		||||
		g_assert (points->length < points->size);
 | 
			
		||||
 | 
			
		||||
		if (!lua_istable (L, -1) || lua_objlen (L, -1) != 2)
 | 
			
		||||
		if (!lua_istable (L, -1) || lua_rawlen (L, -1) != 2)
 | 
			
		||||
			goto read_terminals_fail;
 | 
			
		||||
 | 
			
		||||
		lua_rawgeti (L, -1, 1);
 | 
			
		||||
@@ -614,32 +664,6 @@ read_terminals_fail:
 | 
			
		||||
 | 
			
		||||
/* ===== 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
 | 
			
		||||
get_cairo_scale (cairo_t *cr)
 | 
			
		||||
{
 | 
			
		||||
@@ -649,16 +673,27 @@ get_cairo_scale (cairo_t *cr)
 | 
			
		||||
	return dx;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define LD_LUA_CAIRO_TRIVIAL(name) \
 | 
			
		||||
#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) \
 | 
			
		||||
static int \
 | 
			
		||||
ld_lua_cairo_ ## name (lua_State *L) \
 | 
			
		||||
{ \
 | 
			
		||||
	LdLuaDrawData *data; \
 | 
			
		||||
	data = lua_touserdata (L, lua_upvalueindex (1)); \
 | 
			
		||||
	cairo_ ## name (data->cr); \
 | 
			
		||||
	return 0; \
 | 
			
		||||
 | 
			
		||||
#define LD_LUA_CAIRO_END(n_values) \
 | 
			
		||||
	return (n_values); \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define LD_LUA_CAIRO_TRIVIAL(name) \
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (name) \
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA \
 | 
			
		||||
	cairo_ ## name (data->cr); \
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 | 
			
		||||
LD_LUA_CAIRO_TRIVIAL (new_path)
 | 
			
		||||
LD_LUA_CAIRO_TRIVIAL (new_sub_path)
 | 
			
		||||
LD_LUA_CAIRO_TRIVIAL (close_path)
 | 
			
		||||
@@ -670,138 +705,157 @@ LD_LUA_CAIRO_TRIVIAL (fill_preserve)
 | 
			
		||||
LD_LUA_CAIRO_TRIVIAL (clip)
 | 
			
		||||
LD_LUA_CAIRO_TRIVIAL (clip_preserve)
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
ld_lua_cairo_save (lua_State *L)
 | 
			
		||||
{
 | 
			
		||||
	LdLuaDrawData *data;
 | 
			
		||||
 | 
			
		||||
	data = lua_touserdata (L, lua_upvalueindex (1));
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (save)
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	if (data->save_count + 1)
 | 
			
		||||
	{
 | 
			
		||||
		data->save_count++;
 | 
			
		||||
		cairo_save (data->cr);
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
ld_lua_cairo_restore (lua_State *L)
 | 
			
		||||
{
 | 
			
		||||
	LdLuaDrawData *data;
 | 
			
		||||
 | 
			
		||||
	data = lua_touserdata (L, lua_upvalueindex (1));
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (restore)
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	if (data->save_count)
 | 
			
		||||
	{
 | 
			
		||||
		data->save_count--;
 | 
			
		||||
		cairo_restore (data->cr);
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
ld_lua_cairo_get_line_width (lua_State *L)
 | 
			
		||||
{
 | 
			
		||||
	LdLuaDrawData *data;
 | 
			
		||||
 | 
			
		||||
	data = lua_touserdata (L, lua_upvalueindex (1));
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (get_line_width)
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	lua_pushnumber (L, cairo_get_line_width (data->cr)
 | 
			
		||||
		* get_cairo_scale (data->cr));
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
LD_LUA_CAIRO_END (1)
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
ld_lua_cairo_set_line_width (lua_State *L)
 | 
			
		||||
{
 | 
			
		||||
	LdLuaDrawData *data;
 | 
			
		||||
 | 
			
		||||
	data = lua_touserdata (L, lua_upvalueindex (1));
 | 
			
		||||
	cairo_set_line_width (data->cr, luaL_checknumber (L, 1)
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (set_line_width)
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	cairo_set_line_width (data->cr, luaL_checknumber (L, 2)
 | 
			
		||||
		/ get_cairo_scale (data->cr));
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
ld_lua_cairo_move_to (lua_State *L)
 | 
			
		||||
{
 | 
			
		||||
	LdLuaDrawData *data;
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (translate)
 | 
			
		||||
	lua_Number x, y;
 | 
			
		||||
 | 
			
		||||
	data = lua_touserdata (L, lua_upvalueindex (1));
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	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);
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (scale)
 | 
			
		||||
	lua_Number sx, sy;
 | 
			
		||||
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	sx = luaL_checknumber (L, 2);
 | 
			
		||||
	sy = luaL_checknumber (L, 3);
 | 
			
		||||
 | 
			
		||||
	cairo_scale (data->cr, sx, sy);
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (rotate)
 | 
			
		||||
	lua_Number angle;
 | 
			
		||||
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	angle = luaL_checknumber (L, 2);
 | 
			
		||||
	cairo_rotate (data->cr, angle);
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (move_to)
 | 
			
		||||
	lua_Number x, y;
 | 
			
		||||
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	x = luaL_checknumber (L, 2);
 | 
			
		||||
	y = luaL_checknumber (L, 3);
 | 
			
		||||
 | 
			
		||||
	cairo_move_to (data->cr, x, y);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
ld_lua_cairo_line_to (lua_State *L)
 | 
			
		||||
{
 | 
			
		||||
	LdLuaDrawData *data;
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (line_to)
 | 
			
		||||
	lua_Number x, y;
 | 
			
		||||
 | 
			
		||||
	data = lua_touserdata (L, lua_upvalueindex (1));
 | 
			
		||||
 | 
			
		||||
	x = luaL_checknumber (L, 1);
 | 
			
		||||
	y = luaL_checknumber (L, 2);
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	x = luaL_checknumber (L, 2);
 | 
			
		||||
	y = luaL_checknumber (L, 3);
 | 
			
		||||
 | 
			
		||||
	cairo_line_to (data->cr, x, y);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
ld_lua_cairo_curve_to (lua_State *L)
 | 
			
		||||
{
 | 
			
		||||
	LdLuaDrawData *data;
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (curve_to)
 | 
			
		||||
	lua_Number x1, y1, x2, y2, x3, y3;
 | 
			
		||||
 | 
			
		||||
	data = lua_touserdata (L, lua_upvalueindex (1));
 | 
			
		||||
 | 
			
		||||
	x1 = luaL_checknumber (L, 1);
 | 
			
		||||
	y1 = luaL_checknumber (L, 2);
 | 
			
		||||
	x2 = luaL_checknumber (L, 3);
 | 
			
		||||
	y2 = luaL_checknumber (L, 4);
 | 
			
		||||
	x3 = luaL_checknumber (L, 5);
 | 
			
		||||
	y3 = luaL_checknumber (L, 6);
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	x1 = luaL_checknumber (L, 2);
 | 
			
		||||
	y1 = luaL_checknumber (L, 3);
 | 
			
		||||
	x2 = luaL_checknumber (L, 4);
 | 
			
		||||
	y2 = luaL_checknumber (L, 5);
 | 
			
		||||
	x3 = luaL_checknumber (L, 6);
 | 
			
		||||
	y3 = luaL_checknumber (L, 7);
 | 
			
		||||
 | 
			
		||||
	cairo_curve_to (data->cr, x1, y1, x2, y2, x3, y3);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
ld_lua_cairo_arc (lua_State *L)
 | 
			
		||||
{
 | 
			
		||||
	LdLuaDrawData *data;
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (arc)
 | 
			
		||||
	lua_Number xc, yc, radius, angle1, angle2;
 | 
			
		||||
 | 
			
		||||
	data = lua_touserdata (L, lua_upvalueindex (1));
 | 
			
		||||
 | 
			
		||||
	xc = luaL_checknumber (L, 1);
 | 
			
		||||
	yc = luaL_checknumber (L, 2);
 | 
			
		||||
	radius = luaL_checknumber (L, 3);
 | 
			
		||||
	angle1 = luaL_checknumber (L, 4);
 | 
			
		||||
	angle2 = luaL_checknumber (L, 5);
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	xc = luaL_checknumber (L, 2);
 | 
			
		||||
	yc = luaL_checknumber (L, 3);
 | 
			
		||||
	radius = luaL_checknumber (L, 4);
 | 
			
		||||
	angle1 = luaL_checknumber (L, 5);
 | 
			
		||||
	angle2 = luaL_checknumber (L, 6);
 | 
			
		||||
 | 
			
		||||
	cairo_arc (data->cr, xc, yc, radius, angle1, angle2);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
ld_lua_cairo_arc_negative (lua_State *L)
 | 
			
		||||
{
 | 
			
		||||
	LdLuaDrawData *data;
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (arc_negative)
 | 
			
		||||
	lua_Number xc, yc, radius, angle1, angle2;
 | 
			
		||||
 | 
			
		||||
	data = lua_touserdata (L, lua_upvalueindex (1));
 | 
			
		||||
 | 
			
		||||
	xc = luaL_checknumber (L, 1);
 | 
			
		||||
	yc = luaL_checknumber (L, 2);
 | 
			
		||||
	radius = luaL_checknumber (L, 3);
 | 
			
		||||
	angle1 = luaL_checknumber (L, 4);
 | 
			
		||||
	angle2 = luaL_checknumber (L, 5);
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	xc = luaL_checknumber (L, 2);
 | 
			
		||||
	yc = luaL_checknumber (L, 3);
 | 
			
		||||
	radius = luaL_checknumber (L, 4);
 | 
			
		||||
	angle1 = luaL_checknumber (L, 5);
 | 
			
		||||
	angle2 = luaL_checknumber (L, 6);
 | 
			
		||||
 | 
			
		||||
	cairo_arc_negative (data->cr, xc, yc, radius, angle1, angle2);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 | 
			
		||||
LD_LUA_CAIRO_BEGIN (show_text)
 | 
			
		||||
	const char *text;
 | 
			
		||||
	GtkStyleContext *style;
 | 
			
		||||
	const PangoFontDescription *orig_font_desc;
 | 
			
		||||
	PangoFontDescription *font_desc;
 | 
			
		||||
	PangoLayout *layout;
 | 
			
		||||
	int width, height;
 | 
			
		||||
	double x, y;
 | 
			
		||||
 | 
			
		||||
	LD_LUA_CAIRO_GET_DATA
 | 
			
		||||
	text = luaL_checkstring (L, 2);
 | 
			
		||||
 | 
			
		||||
	layout = pango_cairo_create_layout (data->cr);
 | 
			
		||||
	pango_layout_set_text (layout, text, -1);
 | 
			
		||||
 | 
			
		||||
	style = gtk_style_context_new ();
 | 
			
		||||
	gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL,
 | 
			
		||||
		GTK_STYLE_PROPERTY_FONT, &orig_font_desc, NULL);
 | 
			
		||||
	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);
 | 
			
		||||
 | 
			
		||||
	pango_layout_get_size (layout, &width, &height);
 | 
			
		||||
	cairo_get_current_point (data->cr, &x, &y);
 | 
			
		||||
	x -= (double) width  / PANGO_SCALE / 2;
 | 
			
		||||
	y -= (double) height / PANGO_SCALE / 2;
 | 
			
		||||
 | 
			
		||||
	cairo_save (data->cr);
 | 
			
		||||
	cairo_move_to (data->cr, x, y);
 | 
			
		||||
	pango_cairo_show_layout (data->cr, layout);
 | 
			
		||||
	cairo_restore (data->cr);
 | 
			
		||||
 | 
			
		||||
	g_object_unref (layout);
 | 
			
		||||
LD_LUA_CAIRO_END (0)
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-lua.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010. All rights reserved.
 | 
			
		||||
 * Copyright 2010 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -15,16 +15,14 @@ G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#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_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
 | 
			
		||||
	((klass), LD_TYPE_LUA, LdLuaClass))
 | 
			
		||||
#define LD_IS_LUA(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((obj), LD_TYPE_LUA))
 | 
			
		||||
#define LD_IS_LUA_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((klass), LD_TYPE_LUA))
 | 
			
		||||
#define LD_LUA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
 | 
			
		||||
	((obj), LD_LUA, LdLuaClass))
 | 
			
		||||
#define LD_LUA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_LUA, LdLua))
 | 
			
		||||
#define LD_LUA_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_LUA, LdLuaClass))
 | 
			
		||||
#define LD_IS_LUA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_LUA))
 | 
			
		||||
#define LD_IS_LUA_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((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 _LdLuaPrivate LdLuaPrivate;
 | 
			
		||||
@@ -67,4 +65,3 @@ gboolean ld_lua_load_file (LdLua *self, const gchar *filename,
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_LUA_H__ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,339 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1,79 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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__ */
 | 
			
		||||
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-symbol.c
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -15,9 +15,9 @@
 | 
			
		||||
/**
 | 
			
		||||
 * SECTION:ld-symbol
 | 
			
		||||
 * @short_description: A symbol
 | 
			
		||||
 * @see_also: #LdDiagramSymbol, #LdCanvas
 | 
			
		||||
 * @see_also: #LdDiagramSymbol, #LdDiagramView
 | 
			
		||||
 *
 | 
			
		||||
 * #LdSymbol represents a symbol to be drawn onto a #LdCanvas.
 | 
			
		||||
 * #LdSymbol represents a symbol to be drawn by #LdDiagramView.
 | 
			
		||||
 *
 | 
			
		||||
 * All implementations of this abstract class are required to use
 | 
			
		||||
 * cairo_save() and cairo_restore() when drawing to store the state.
 | 
			
		||||
@@ -38,7 +38,7 @@ static void ld_symbol_set_property (GObject *object, guint property_id,
 | 
			
		||||
	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
 | 
			
		||||
ld_symbol_class_init (LdSymbolClass *klass)
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-symbol.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -15,16 +15,15 @@ G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define LD_TYPE_SYMBOL (ld_symbol_get_type ())
 | 
			
		||||
#define LD_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST \
 | 
			
		||||
	((obj), LD_TYPE_SYMBOL, LdSymbol))
 | 
			
		||||
#define LD_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
 | 
			
		||||
	((klass), LD_TYPE_SYMBOL, LdSymbolClass))
 | 
			
		||||
#define LD_IS_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((obj), LD_TYPE_SYMBOL))
 | 
			
		||||
#define LD_IS_SYMBOL_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((klass), LD_TYPE_SYMBOL))
 | 
			
		||||
#define LD_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
 | 
			
		||||
	((obj), LD_SYMBOL, LdSymbolClass))
 | 
			
		||||
#define LD_SYMBOL(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_SYMBOL, LdSymbol))
 | 
			
		||||
#define LD_SYMBOL_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_SYMBOL, LdSymbolClass))
 | 
			
		||||
#define LD_IS_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_SYMBOL))
 | 
			
		||||
#define LD_IS_SYMBOL_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_SYMBOL))
 | 
			
		||||
#define LD_SYMBOL_GET_CLASS(obj) \
 | 
			
		||||
	(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_SYMBOL, LdSymbolClass))
 | 
			
		||||
 | 
			
		||||
typedef struct _LdSymbol LdSymbol;
 | 
			
		||||
typedef struct _LdSymbolPrivate LdSymbolPrivate;
 | 
			
		||||
@@ -72,4 +71,3 @@ void ld_symbol_draw (LdSymbol *self, cairo_t *cr);
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_SYMBOL_H__ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-types.c
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -256,7 +256,8 @@ ld_point_array_remove (LdPointArray *self, gint pos, guint length)
 | 
			
		||||
 *
 | 
			
		||||
 * Change size of the array.
 | 
			
		||||
 */
 | 
			
		||||
void ld_point_array_set_size (LdPointArray *self, guint size)
 | 
			
		||||
void
 | 
			
		||||
ld_point_array_set_size (LdPointArray *self, guint size)
 | 
			
		||||
{
 | 
			
		||||
	g_return_if_fail (self != NULL);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-types.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2010, 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -14,13 +14,9 @@
 | 
			
		||||
G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define LD_TYPE_POINT (ld_point_get_type ())
 | 
			
		||||
#define LD_TYPE_POINT       (ld_point_get_type ())
 | 
			
		||||
#define LD_TYPE_POINT_ARRAY (ld_point_array_get_type ())
 | 
			
		||||
#define LD_TYPE_RECTANGLE (ld_rectangle_get_type ())
 | 
			
		||||
 | 
			
		||||
typedef struct _LdPoint LdPoint;
 | 
			
		||||
typedef struct _LdPointArray LdPointArray;
 | 
			
		||||
typedef struct _LdRectangle LdRectangle;
 | 
			
		||||
#define LD_TYPE_RECTANGLE   (ld_rectangle_get_type ())
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -30,10 +26,11 @@ typedef struct _LdRectangle LdRectangle;
 | 
			
		||||
 *
 | 
			
		||||
 * Defines a point.
 | 
			
		||||
 */
 | 
			
		||||
struct _LdPoint
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
	gdouble x, y;
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
LdPoint;
 | 
			
		||||
 | 
			
		||||
GType ld_point_get_type (void) G_GNUC_CONST;
 | 
			
		||||
 | 
			
		||||
@@ -50,12 +47,13 @@ gdouble ld_point_distance (const LdPoint *self, gdouble x, gdouble y);
 | 
			
		||||
 *
 | 
			
		||||
 * Defines an array of points.
 | 
			
		||||
 */
 | 
			
		||||
struct _LdPointArray
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
	LdPoint *points;
 | 
			
		||||
	guint length;
 | 
			
		||||
	guint size;
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
LdPointArray;
 | 
			
		||||
 | 
			
		||||
GType ld_point_array_get_type (void) G_GNUC_CONST;
 | 
			
		||||
 | 
			
		||||
@@ -78,11 +76,12 @@ void ld_point_array_set_size (LdPointArray *self, guint size);
 | 
			
		||||
 *
 | 
			
		||||
 * Defines a rectangle.
 | 
			
		||||
 */
 | 
			
		||||
struct _LdRectangle
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
	gdouble x, y;
 | 
			
		||||
	gdouble width, height;
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
LdRectangle;
 | 
			
		||||
 | 
			
		||||
GType ld_rectangle_get_type (void) G_GNUC_CONST;
 | 
			
		||||
 | 
			
		||||
@@ -100,4 +99,3 @@ void ld_rectangle_extend (LdRectangle *self, gdouble border);
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_TYPES_H__ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-undo-action.c
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -40,7 +40,7 @@ struct _LdUndoActionPrivate
 | 
			
		||||
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
 | 
			
		||||
ld_undo_action_class_init (LdUndoActionClass *klass)
 | 
			
		||||
@@ -84,9 +84,8 @@ ld_undo_action_finalize (GObject *gobject)
 | 
			
		||||
 * Return value: a new #LdUndoAction object.
 | 
			
		||||
 */
 | 
			
		||||
LdUndoAction *
 | 
			
		||||
ld_undo_action_new (LdUndoActionFunc undo_func,
 | 
			
		||||
	LdUndoActionFunc redo_func, LdUndoActionFunc destroy_func,
 | 
			
		||||
	gpointer user_data)
 | 
			
		||||
ld_undo_action_new (LdUndoActionFunc undo_func, LdUndoActionFunc redo_func,
 | 
			
		||||
	LdUndoActionFunc destroy_func, gpointer user_data)
 | 
			
		||||
{
 | 
			
		||||
	LdUndoAction *self;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * ld-undo-action.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2011 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * 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_UNDO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST \
 | 
			
		||||
	((obj), LD_TYPE_UNDO_ACTION, LdUndoAction))
 | 
			
		||||
#define LD_UNDO_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
 | 
			
		||||
	((klass), LD_TYPE_UNDO_ACTION, LdUndoActionClass))
 | 
			
		||||
#define LD_IS_UNDO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((obj), LD_TYPE_UNDO_ACTION))
 | 
			
		||||
#define LD_IS_UNDO_ACTION_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
 | 
			
		||||
	((klass), LD_TYPE_UNDO_ACTION))
 | 
			
		||||
#define LD_UNDO_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
 | 
			
		||||
	((obj), LD_UNDO_ACTION, LdUndoActionClass))
 | 
			
		||||
#define LD_UNDO_ACTION(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_CAST ((obj), LD_TYPE_UNDO_ACTION, LdUndoAction))
 | 
			
		||||
#define LD_UNDO_ACTION_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_CLASS_CAST ((klass), LD_TYPE_UNDO_ACTION, LdUndoActionClass))
 | 
			
		||||
#define LD_IS_UNDO_ACTION(obj) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), LD_TYPE_UNDO_ACTION))
 | 
			
		||||
#define LD_IS_UNDO_ACTION_CLASS(klass) \
 | 
			
		||||
	(G_TYPE_CHECK_INSTANCE_TYPE ((klass), LD_TYPE_UNDO_ACTION))
 | 
			
		||||
#define LD_UNDO_ACTION_GET_CLASS(obj) \
 | 
			
		||||
	(G_TYPE_INSTANCE_GET_CLASS ((obj), LD_UNDO_ACTION, LdUndoActionClass))
 | 
			
		||||
 | 
			
		||||
typedef struct _LdUndoAction LdUndoAction;
 | 
			
		||||
typedef struct _LdUndoActionPrivate LdUndoActionPrivate;
 | 
			
		||||
@@ -73,4 +73,3 @@ void ld_undo_action_redo (LdUndoAction *self);
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* ! __LD_UNDO_ACTION_H__ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * liblogdiag.h
 | 
			
		||||
 *
 | 
			
		||||
 * This file is a part of logdiag.
 | 
			
		||||
 * Copyright Přemysl Janouch 2011. All rights reserved.
 | 
			
		||||
 * Copyright 2011, 2012 Přemysl Eric Janouch
 | 
			
		||||
 *
 | 
			
		||||
 * See the file LICENSE for licensing information.
 | 
			
		||||
 *
 | 
			
		||||
@@ -11,6 +11,15 @@
 | 
			
		||||
#ifndef __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 <json-glib/json-glib.h>
 | 
			
		||||
 | 
			
		||||
@@ -18,7 +27,7 @@
 | 
			
		||||
#include "ld-types.h"
 | 
			
		||||
 | 
			
		||||
#include "ld-symbol.h"
 | 
			
		||||
#include "ld-symbol-category.h"
 | 
			
		||||
#include "ld-category.h"
 | 
			
		||||
#include "ld-library.h"
 | 
			
		||||
 | 
			
		||||
#include "ld-undo-action.h"
 | 
			
		||||
@@ -27,8 +36,10 @@
 | 
			
		||||
#include "ld-diagram-connection.h"
 | 
			
		||||
#include "ld-diagram.h"
 | 
			
		||||
 | 
			
		||||
#include "ld-canvas.h"
 | 
			
		||||
#include "ld-library-toolbar.h"
 | 
			
		||||
#include "ld-diagram-view.h"
 | 
			
		||||
#include "ld-category-view.h"
 | 
			
		||||
#include "ld-category-symbol-view.h"
 | 
			
		||||
#include "ld-category-tree-view.h"
 | 
			
		||||
 | 
			
		||||
#include "ld-lua.h"
 | 
			
		||||
#include "ld-lua-symbol.h"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										250
									
								
								po/cs.po
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,250 @@
 | 
			
		||||
# Czech translation for logdiag.
 | 
			
		||||
# Copyright (C) 2011 Přemysl Eric Janouch
 | 
			
		||||
# This file is distributed under the same license as the logdiag package.
 | 
			
		||||
# Přemysl Eric Janouch <p@janouch.name>, 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-22 22:16+0200\n"
 | 
			
		||||
"PO-Revision-Date: 2021-10-22 22:21+0200\n"
 | 
			
		||||
"Last-Translator: Přemysl Eric Janouch <p@janouch.name>\n"
 | 
			
		||||
"Language-Team: Czech <cs@li.org>\n"
 | 
			
		||||
"Language: cs\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:937
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid "%d%%"
 | 
			
		||||
msgstr "%d %%"
 | 
			
		||||
 | 
			
		||||
#: ../src/logdiag.c:147
 | 
			
		||||
msgid "- Schematic editor"
 | 
			
		||||
msgstr "- Editor schémat"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:861
 | 
			
		||||
msgid "Close _without Saving"
 | 
			
		||||
msgstr "Zavřít _bez uložení"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:128
 | 
			
		||||
msgid "Create a new diagram"
 | 
			
		||||
msgstr "Vytvoří nový diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:161
 | 
			
		||||
msgid "Delete the contents of the selection"
 | 
			
		||||
msgstr "Odstraní obsah výběru"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:354
 | 
			
		||||
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:707
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid "Failed to open file `%s': Invalid contents."
 | 
			
		||||
msgstr "Nelze otevřít soubor \"%s\": Neplatný obsah."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:698
 | 
			
		||||
msgid "Failed to open the file"
 | 
			
		||||
msgstr "Nelze otevřít soubor"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:662
 | 
			
		||||
msgid "Failed to save the diagram"
 | 
			
		||||
msgstr "Nelze uložit diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:859
 | 
			
		||||
msgid "If you don't save, changes will be permanently lost."
 | 
			
		||||
msgstr "Pokud je neuložíte, budou změny navždy ztraceny."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:738
 | 
			
		||||
msgid "Logdiag Diagrams (*.ldd)"
 | 
			
		||||
msgstr "Diagramy logdiag (*.ldd)"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:131
 | 
			
		||||
msgid "Open a diagram"
 | 
			
		||||
msgstr "Otevře diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:759
 | 
			
		||||
msgid "Open..."
 | 
			
		||||
msgstr "Otevřít..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:145
 | 
			
		||||
msgid "Quit the application"
 | 
			
		||||
msgstr "Ukončí aplikaci"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:153
 | 
			
		||||
msgid "Redo the last undone action"
 | 
			
		||||
msgstr "Provede posledně vrácenou akci"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:175
 | 
			
		||||
msgid "Reset zoom level back to the default"
 | 
			
		||||
msgstr "Vrátí přiblížení na výchozí hodnotu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:792
 | 
			
		||||
msgid "Save As..."
 | 
			
		||||
msgstr "Uložit jako..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:136
 | 
			
		||||
msgid "Save _As..."
 | 
			
		||||
msgstr "Uložit _jako..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:623
 | 
			
		||||
#, c-format
 | 
			
		||||
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?"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:755
 | 
			
		||||
#, c-format
 | 
			
		||||
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?"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:899
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid "Save the changes to diagram \"%s\" before closing?"
 | 
			
		||||
msgstr "Uložit změny v diagramu \"%s\" před jeho zavřením?"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:134
 | 
			
		||||
msgid "Save the current diagram"
 | 
			
		||||
msgstr "Uloží stávající diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:137
 | 
			
		||||
msgid "Save the current diagram with another name"
 | 
			
		||||
msgstr "Uloží stávající diagram pod jiným jménem"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:163
 | 
			
		||||
msgid "Select _All"
 | 
			
		||||
msgstr "Vybrat _vše"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:164
 | 
			
		||||
msgid "Select all objects in the diagram"
 | 
			
		||||
msgstr "Vybere všechny objekty v diagramu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:192
 | 
			
		||||
msgid "Show _Grid"
 | 
			
		||||
msgstr "Zobrazit _mřížku"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:180
 | 
			
		||||
msgid "Show a dialog about this application"
 | 
			
		||||
msgstr "Zobrazí dialog o této aplikaci"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:193
 | 
			
		||||
msgid "Toggle displaying of the grid"
 | 
			
		||||
msgstr "Přepne zobrazování mřížky"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:190
 | 
			
		||||
msgid "Toggle displaying of the library pane"
 | 
			
		||||
msgstr "Přepne zobrazování panelu knihovny"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:187
 | 
			
		||||
msgid "Toggle displaying of the main toolbar"
 | 
			
		||||
msgstr "Přepne zobrazování hlavního panelu nástrojů"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:665
 | 
			
		||||
msgid "Try again or save it under another name."
 | 
			
		||||
msgstr "Zkuste to znova nebo jej uložte pod jiným názvem."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:150
 | 
			
		||||
msgid "Undo the last action"
 | 
			
		||||
msgstr "Vrátí poslední akci"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:591
 | 
			
		||||
msgid "Unsaved Diagram"
 | 
			
		||||
msgstr "Neuložený diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:806
 | 
			
		||||
msgid "Untitled diagram"
 | 
			
		||||
msgstr "Nepojmenovaný diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:171
 | 
			
		||||
msgid "Zoom _Out"
 | 
			
		||||
msgstr "_Oddálit"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:169
 | 
			
		||||
msgid "Zoom into the diagram"
 | 
			
		||||
msgstr "Přiblíží diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:172
 | 
			
		||||
msgid "Zoom out of the diagram"
 | 
			
		||||
msgstr "Oddálí diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/logdiag.c:106
 | 
			
		||||
msgid "[FILE...]"
 | 
			
		||||
msgstr "[SOUBOR...]"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:179
 | 
			
		||||
msgid "_About"
 | 
			
		||||
msgstr "_O programu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:160
 | 
			
		||||
msgid "_Delete"
 | 
			
		||||
msgstr "_Smazat"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:148
 | 
			
		||||
msgid "_Edit"
 | 
			
		||||
msgstr "_Úpravy"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:126
 | 
			
		||||
msgid "_File"
 | 
			
		||||
msgstr "_Soubor"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:178
 | 
			
		||||
msgid "_Help"
 | 
			
		||||
msgstr "_Nápověda"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:189
 | 
			
		||||
msgid "_Library Pane"
 | 
			
		||||
msgstr "Panel _knihovny"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:186
 | 
			
		||||
msgid "_Main Toolbar"
 | 
			
		||||
msgstr "_Hlavní panel nástrojů"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:127
 | 
			
		||||
msgid "_New"
 | 
			
		||||
msgstr "_Nový"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:174
 | 
			
		||||
msgid "_Normal Size"
 | 
			
		||||
msgstr "_Normální velikost"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:130
 | 
			
		||||
msgid "_Open..."
 | 
			
		||||
msgstr "_Otevřít..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:144
 | 
			
		||||
msgid "_Quit"
 | 
			
		||||
msgstr "U_končit"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:152
 | 
			
		||||
msgid "_Redo"
 | 
			
		||||
msgstr "Z_novu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:133
 | 
			
		||||
msgid "_Save"
 | 
			
		||||
msgstr "_Uložit"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:149
 | 
			
		||||
msgid "_Undo"
 | 
			
		||||
msgstr "_Zpět"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:167
 | 
			
		||||
msgid "_View"
 | 
			
		||||
msgstr "_Zobrazení"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:168
 | 
			
		||||
msgid "_Zoom In"
 | 
			
		||||
msgstr "_Přiblížit"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:983
 | 
			
		||||
msgid "translator-credits"
 | 
			
		||||
msgstr "Přemysl Eric Janouch <p@janouch.name>"
 | 
			
		||||
 | 
			
		||||
#~ msgid "The file is probably corrupted."
 | 
			
		||||
#~ msgstr "Soubor je pravděpodobně poškozen."
 | 
			
		||||
							
								
								
									
										257
									
								
								po/de.po
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,257 @@
 | 
			
		||||
# 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-22 22:16+0200\n"
 | 
			
		||||
"PO-Revision-Date: 2018-06-25 04:11+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 2.0.8\n"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:937
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid "%d%%"
 | 
			
		||||
msgstr "%d %%"
 | 
			
		||||
 | 
			
		||||
#: ../src/logdiag.c:147
 | 
			
		||||
msgid "- Schematic editor"
 | 
			
		||||
msgstr "- Schema Editor"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:861
 | 
			
		||||
msgid "Close _without Saving"
 | 
			
		||||
msgstr "Schließen _ohne Speichern"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:128
 | 
			
		||||
msgid "Create a new diagram"
 | 
			
		||||
msgstr "Neues Diagramm erstellen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:161
 | 
			
		||||
msgid "Delete the contents of the selection"
 | 
			
		||||
msgstr "Inhalt der markierten Einträge löschen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:354
 | 
			
		||||
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:707
 | 
			
		||||
#, 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:698
 | 
			
		||||
msgid "Failed to open the file"
 | 
			
		||||
msgstr "Fehler beim Öffnen der Datei"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:662
 | 
			
		||||
msgid "Failed to save the diagram"
 | 
			
		||||
msgstr "Fehler beim Speichern des Diagramms"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:859
 | 
			
		||||
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:738
 | 
			
		||||
msgid "Logdiag Diagrams (*.ldd)"
 | 
			
		||||
msgstr "Diagramme logdiag (.ldd)"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:131
 | 
			
		||||
msgid "Open a diagram"
 | 
			
		||||
msgstr "Diagramm öffnen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:759
 | 
			
		||||
msgid "Open..."
 | 
			
		||||
msgstr "Öffnen..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:145
 | 
			
		||||
msgid "Quit the application"
 | 
			
		||||
msgstr "Anwendung beenden"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:153
 | 
			
		||||
msgid "Redo the last undone action"
 | 
			
		||||
msgstr "Letzte nicht abgeschlossene Aktion wiederholen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:175
 | 
			
		||||
msgid "Reset zoom level back to the default"
 | 
			
		||||
msgstr "Zoom Bereich zurücksetzen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:792
 | 
			
		||||
msgid "Save As..."
 | 
			
		||||
msgstr "Speichern unter..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:136
 | 
			
		||||
msgid "Save _As..."
 | 
			
		||||
msgstr "Speichern _unter..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:623
 | 
			
		||||
#, 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:755
 | 
			
		||||
#, 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:899
 | 
			
		||||
#, 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:134
 | 
			
		||||
msgid "Save the current diagram"
 | 
			
		||||
msgstr "Speichern des aktuellen Diagramms"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:137
 | 
			
		||||
msgid "Save the current diagram with another name"
 | 
			
		||||
msgstr "Aktuelles Diagramm unter anderem Namen speichern"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:163
 | 
			
		||||
msgid "Select _All"
 | 
			
		||||
msgstr "_Alles Auswählen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:164
 | 
			
		||||
msgid "Select all objects in the diagram"
 | 
			
		||||
msgstr "Alle Objekte im Diagramm auswählen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:192
 | 
			
		||||
msgid "Show _Grid"
 | 
			
		||||
msgstr "_Gitter anzeigen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:180
 | 
			
		||||
msgid "Show a dialog about this application"
 | 
			
		||||
msgstr "Zeige einen Dialog über diese Anwendung"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:193
 | 
			
		||||
msgid "Toggle displaying of the grid"
 | 
			
		||||
msgstr "Gitter ein-/ausblenden"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:190
 | 
			
		||||
msgid "Toggle displaying of the library pane"
 | 
			
		||||
msgstr "Bibliothek ein-/ausblenden"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:187
 | 
			
		||||
msgid "Toggle displaying of the main toolbar"
 | 
			
		||||
msgstr "Symbolleiste ein-/ausblenden"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:665
 | 
			
		||||
msgid "Try again or save it under another name."
 | 
			
		||||
msgstr "Erneuter Versuch oder unter anderem Namen speichern."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:150
 | 
			
		||||
msgid "Undo the last action"
 | 
			
		||||
msgstr "Letzte Aktion rückgangig machen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:591
 | 
			
		||||
msgid "Unsaved Diagram"
 | 
			
		||||
msgstr "Ungespeichertes Diagramm"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:806
 | 
			
		||||
#, fuzzy
 | 
			
		||||
msgid "Untitled diagram"
 | 
			
		||||
msgstr "Ungespeichertes Diagramm"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:171
 | 
			
		||||
msgid "Zoom _Out"
 | 
			
		||||
msgstr "Zoom _heraus"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:169
 | 
			
		||||
msgid "Zoom into the diagram"
 | 
			
		||||
msgstr "In das Diagramm zoomen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:172
 | 
			
		||||
msgid "Zoom out of the diagram"
 | 
			
		||||
msgstr "Aus dem Diagramm zoomen"
 | 
			
		||||
 | 
			
		||||
#: ../src/logdiag.c:106
 | 
			
		||||
msgid "[FILE...]"
 | 
			
		||||
msgstr "[DATEI...]"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:179
 | 
			
		||||
msgid "_About"
 | 
			
		||||
msgstr "_Über"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:160
 | 
			
		||||
msgid "_Delete"
 | 
			
		||||
msgstr "_Löschen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:148
 | 
			
		||||
msgid "_Edit"
 | 
			
		||||
msgstr "_Ändern"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:126
 | 
			
		||||
msgid "_File"
 | 
			
		||||
msgstr "_Datei"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:178
 | 
			
		||||
msgid "_Help"
 | 
			
		||||
msgstr "_Hilfe"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:189
 | 
			
		||||
msgid "_Library Pane"
 | 
			
		||||
msgstr "_Bibliothek Menüleiste"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:186
 | 
			
		||||
msgid "_Main Toolbar"
 | 
			
		||||
msgstr "_Symbolleiste"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:127
 | 
			
		||||
msgid "_New"
 | 
			
		||||
msgstr "_Neu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:174
 | 
			
		||||
msgid "_Normal Size"
 | 
			
		||||
msgstr "_Normale Größe"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:130
 | 
			
		||||
msgid "_Open..."
 | 
			
		||||
msgstr "_Öffnen..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:144
 | 
			
		||||
msgid "_Quit"
 | 
			
		||||
msgstr "_Beenden"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:152
 | 
			
		||||
msgid "_Redo"
 | 
			
		||||
msgstr "_Wiederholen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:133
 | 
			
		||||
msgid "_Save"
 | 
			
		||||
msgstr "_Speichern"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:149
 | 
			
		||||
msgid "_Undo"
 | 
			
		||||
msgstr "_Rückgängig"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:167
 | 
			
		||||
msgid "_View"
 | 
			
		||||
msgstr "_Ansicht"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:168
 | 
			
		||||
msgid "_Zoom In"
 | 
			
		||||
msgstr "_Hineinzoomen"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:983
 | 
			
		||||
msgid "translator-credits"
 | 
			
		||||
msgstr "Andy J."
 | 
			
		||||
 | 
			
		||||
#~ msgid "The file is probably corrupted."
 | 
			
		||||
#~ msgstr "Die Datei ist vermutlich beschädigt."
 | 
			
		||||
							
								
								
									
										242
									
								
								po/logdiag.pot
									
									
									
									
									
								
							
							
						
						@@ -1,14 +1,14 @@
 | 
			
		||||
# SOME DESCRIPTIVE TITLE.
 | 
			
		||||
# Copyright (C) YEAR Přemysl Janouch
 | 
			
		||||
# This file is distributed under the same license as the PACKAGE package.
 | 
			
		||||
# Copyright (C) YEAR Přemysl Eric Janouch
 | 
			
		||||
# This file is distributed under the same license as the logdiag package.
 | 
			
		||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
 | 
			
		||||
#
 | 
			
		||||
#, fuzzy
 | 
			
		||||
msgid ""
 | 
			
		||||
msgstr ""
 | 
			
		||||
"Project-Id-Version: logdiag \n"
 | 
			
		||||
"Report-Msgid-Bugs-To: \n"
 | 
			
		||||
"POT-Creation-Date: 2010-07-05 23:23+0200\n"
 | 
			
		||||
"Project-Id-Version: logdiag 0.2.0\n"
 | 
			
		||||
"Report-Msgid-Bugs-To: https://git.janouch.name/p/logdiag/issues\n"
 | 
			
		||||
"POT-Creation-Date: 2021-10-22 22:16+0200\n"
 | 
			
		||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 | 
			
		||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 | 
			
		||||
"Language-Team: LANGUAGE <LL@li.org>\n"
 | 
			
		||||
@@ -17,7 +17,233 @@ msgstr ""
 | 
			
		||||
"Content-Type: text/plain; charset=UTF-8\n"
 | 
			
		||||
"Content-Transfer-Encoding: 8bit\n"
 | 
			
		||||
 | 
			
		||||
#: ../src/window-main.c:102
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid "Building UI failed: %s"
 | 
			
		||||
#: ../src/ld-window-main.c:126
 | 
			
		||||
msgid "_File"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:127
 | 
			
		||||
msgid "_New"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:128
 | 
			
		||||
msgid "Create a new diagram"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:130
 | 
			
		||||
msgid "_Open..."
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:131
 | 
			
		||||
msgid "Open a diagram"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:133
 | 
			
		||||
msgid "_Save"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:134
 | 
			
		||||
msgid "Save the current diagram"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:136
 | 
			
		||||
msgid "Save _As..."
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:137
 | 
			
		||||
msgid "Save the current diagram with another name"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:144
 | 
			
		||||
msgid "_Quit"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:145
 | 
			
		||||
msgid "Quit the application"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:148
 | 
			
		||||
msgid "_Edit"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:149
 | 
			
		||||
msgid "_Undo"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:150
 | 
			
		||||
msgid "Undo the last action"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:152
 | 
			
		||||
msgid "_Redo"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:153
 | 
			
		||||
msgid "Redo the last undone action"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:160
 | 
			
		||||
msgid "_Delete"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:161
 | 
			
		||||
msgid "Delete the contents of the selection"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:163
 | 
			
		||||
msgid "Select _All"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:164
 | 
			
		||||
msgid "Select all objects in the diagram"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:167
 | 
			
		||||
msgid "_View"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:168
 | 
			
		||||
msgid "_Zoom In"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:169
 | 
			
		||||
msgid "Zoom into the diagram"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:171
 | 
			
		||||
msgid "Zoom _Out"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:172
 | 
			
		||||
msgid "Zoom out of the diagram"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:174
 | 
			
		||||
msgid "_Normal Size"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:175
 | 
			
		||||
msgid "Reset zoom level back to the default"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:178
 | 
			
		||||
msgid "_Help"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:179
 | 
			
		||||
msgid "_About"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:180
 | 
			
		||||
msgid "Show a dialog about this application"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:186
 | 
			
		||||
msgid "_Main Toolbar"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:187
 | 
			
		||||
msgid "Toggle displaying of the main toolbar"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:189
 | 
			
		||||
msgid "_Library Pane"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:190
 | 
			
		||||
msgid "Toggle displaying of the library pane"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:192
 | 
			
		||||
msgid "Show _Grid"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:193
 | 
			
		||||
msgid "Toggle displaying of the grid"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:354
 | 
			
		||||
msgid "Drag symbols from the library pane to add them to the diagram."
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:591
 | 
			
		||||
msgid "Unsaved Diagram"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:623
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid ""
 | 
			
		||||
"Save the changes to diagram \"%s\" before closing it and creating a new one?"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:662
 | 
			
		||||
msgid "Failed to save the diagram"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:665
 | 
			
		||||
msgid "Try again or save it under another name."
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:698
 | 
			
		||||
msgid "Failed to open the file"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:707
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid "Failed to open file `%s': Invalid contents."
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:738
 | 
			
		||||
msgid "Logdiag Diagrams (*.ldd)"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:755
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid ""
 | 
			
		||||
"Save the changes to diagram \"%s\" before closing it and opening another one?"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:759
 | 
			
		||||
msgid "Open..."
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:792
 | 
			
		||||
msgid "Save As..."
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:806
 | 
			
		||||
msgid "Untitled diagram"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:859
 | 
			
		||||
msgid "If you don't save, changes will be permanently lost."
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:861
 | 
			
		||||
msgid "Close _without Saving"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:899
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid "Save the changes to diagram \"%s\" before closing?"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:937
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid "%d%%"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:983
 | 
			
		||||
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 ""
 | 
			
		||||
 
 | 
			
		||||
@@ -1,36 +1,21 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
# This script makes a translation template
 | 
			
		||||
# The reason for this not being inside CMakeLists.txt
 | 
			
		||||
# is that the translator should not need to run
 | 
			
		||||
# the whole configure process to get this single stupid file.
 | 
			
		||||
#!/bin/sh -e
 | 
			
		||||
# This shell script generates the translation template.
 | 
			
		||||
#
 | 
			
		||||
# The reason for this not being inside CMakeLists.txt is that the translator
 | 
			
		||||
# should not need to run the whole configuration process just to get this file.
 | 
			
		||||
dir=$(dirname $0)
 | 
			
		||||
 | 
			
		||||
# Source files
 | 
			
		||||
SOURCES=$(echo ../{src,liblogdiag}/*.c)
 | 
			
		||||
export LC_ALL=C
 | 
			
		||||
 | 
			
		||||
# Get the package name from CMakeLists.txt
 | 
			
		||||
PACKAGE=$(sed -n '/^[ \t]*[pP][rR][oO][jJ][eE][cC][tT][ \t]*([ \t]*\([^ \t)]\{1,\}\).*).*/{s//\1/p;q}' \
 | 
			
		||||
	../CMakeLists.txt)
 | 
			
		||||
 | 
			
		||||
# Get the package version from CMakeLists.txt
 | 
			
		||||
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
 | 
			
		||||
re='^[ \t]*project *( *\([^ \t)]\{1,\}\) \{1,\}VERSION \{1,\}\([^ \t)]\{1,\}\).*'
 | 
			
		||||
package=$(sed -n "s/$re/\\1/p" "$dir/../CMakeLists.txt")
 | 
			
		||||
version=$(sed -n "s/$re/\\2/p" "$dir/../CMakeLists.txt")
 | 
			
		||||
if [ -z "$package" -o -z "$version" ]; then
 | 
			
		||||
	echo "Failed to get information from CMakeLists.txt"
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Finally make the template
 | 
			
		||||
xgettext -LC -k_ -kN_:1,2 -kG_ $SOURCES -o "$PACKAGE".pot \
 | 
			
		||||
	--package-name="$PACKAGE" --package-version="$VERSION" \
 | 
			
		||||
	--copyright-holder="Přemysl Janouch"
 | 
			
		||||
 | 
			
		||||
xgettext -LC -k_ -kN_ "$dir"/../{src,liblogdiag}/*.c -o "$dir/$package.pot" \
 | 
			
		||||
	--package-name="$package" --package-version="$version" \
 | 
			
		||||
	--copyright-holder="Přemysl Eric Janouch" \
 | 
			
		||||
	--msgid-bugs-address="https://git.janouch.name/p/$package/issues"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										255
									
								
								po/pl.po
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,255 @@
 | 
			
		||||
# 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-22 22:16+0200\n"
 | 
			
		||||
"PO-Revision-Date: 2018-06-25 04:09+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 2.0.8\n"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:937
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid "%d%%"
 | 
			
		||||
msgstr "%d%%"
 | 
			
		||||
 | 
			
		||||
#: ../src/logdiag.c:147
 | 
			
		||||
msgid "- Schematic editor"
 | 
			
		||||
msgstr "- Edytor schematów"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:861
 | 
			
		||||
msgid "Close _without Saving"
 | 
			
		||||
msgstr "Zamknąć _bez zapisu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:128
 | 
			
		||||
msgid "Create a new diagram"
 | 
			
		||||
msgstr "Stworzenie nowego wykresu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:161
 | 
			
		||||
msgid "Delete the contents of the selection"
 | 
			
		||||
msgstr "Usuń zawartość wyboru"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:354
 | 
			
		||||
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:707
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid "Failed to open file `%s': Invalid contents."
 | 
			
		||||
msgstr "Nie można otworzyć pliku \"%s\": Niepoprawna zawartość."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:698
 | 
			
		||||
msgid "Failed to open the file"
 | 
			
		||||
msgstr "Pliku nie da się otworzyć"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:662
 | 
			
		||||
msgid "Failed to save the diagram"
 | 
			
		||||
msgstr "Nie udało się zapisać wykresu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:859
 | 
			
		||||
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:738
 | 
			
		||||
msgid "Logdiag Diagrams (*.ldd)"
 | 
			
		||||
msgstr "Wykresy logdiag (*.ldd)"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:131
 | 
			
		||||
msgid "Open a diagram"
 | 
			
		||||
msgstr "Otwórz wykres"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:759
 | 
			
		||||
msgid "Open..."
 | 
			
		||||
msgstr "Otworzyć..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:145
 | 
			
		||||
msgid "Quit the application"
 | 
			
		||||
msgstr "Zamknie aplikację"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:153
 | 
			
		||||
msgid "Redo the last undone action"
 | 
			
		||||
msgstr "Powtórzy ostatnio cofniętą akcję"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:175
 | 
			
		||||
msgid "Reset zoom level back to the default"
 | 
			
		||||
msgstr "Przywróci poziom zbliżenia na poziom wyjściowy"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:792
 | 
			
		||||
msgid "Save As..."
 | 
			
		||||
msgstr "Zapisz jako..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:136
 | 
			
		||||
msgid "Save _As..."
 | 
			
		||||
msgstr "Zapisz _jako..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:623
 | 
			
		||||
#, 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:755
 | 
			
		||||
#, 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:899
 | 
			
		||||
#, 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:134
 | 
			
		||||
msgid "Save the current diagram"
 | 
			
		||||
msgstr "Zapisz aktywny wykres"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:137
 | 
			
		||||
msgid "Save the current diagram with another name"
 | 
			
		||||
msgstr "Zapisać aktywny wykres pod inną nazwą"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:163
 | 
			
		||||
msgid "Select _All"
 | 
			
		||||
msgstr "Wybierz _wszystko"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:164
 | 
			
		||||
msgid "Select all objects in the diagram"
 | 
			
		||||
msgstr "Wybierze wszystkie obietky w wykresie"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:192
 | 
			
		||||
msgid "Show _Grid"
 | 
			
		||||
msgstr "Pokaż _Siatkę"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:180
 | 
			
		||||
msgid "Show a dialog about this application"
 | 
			
		||||
msgstr "Pokaże informacje o tej aplikacji"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:193
 | 
			
		||||
msgid "Toggle displaying of the grid"
 | 
			
		||||
msgstr "Przełączy pokazywanie siatki"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:190
 | 
			
		||||
msgid "Toggle displaying of the library pane"
 | 
			
		||||
msgstr "Przełączy pokazywanie panelu biblioteki"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:187
 | 
			
		||||
msgid "Toggle displaying of the main toolbar"
 | 
			
		||||
msgstr "Przełączy pokazywanie głównego panelu narzędzi"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:665
 | 
			
		||||
msgid "Try again or save it under another name."
 | 
			
		||||
msgstr "Spróbuj ponownie, bądź zapisz pod inną nazwą."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:150
 | 
			
		||||
msgid "Undo the last action"
 | 
			
		||||
msgstr "Cofnie ostatnią akcję"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:591
 | 
			
		||||
msgid "Unsaved Diagram"
 | 
			
		||||
msgstr "Niezapisany Wykres"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:806
 | 
			
		||||
#, fuzzy
 | 
			
		||||
msgid "Untitled diagram"
 | 
			
		||||
msgstr "Niezapisany Wykres"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:171
 | 
			
		||||
msgid "Zoom _Out"
 | 
			
		||||
msgstr "_Oddalić widok"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:169
 | 
			
		||||
msgid "Zoom into the diagram"
 | 
			
		||||
msgstr "Przybliżyć widok"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:172
 | 
			
		||||
msgid "Zoom out of the diagram"
 | 
			
		||||
msgstr "Oddalić widok"
 | 
			
		||||
 | 
			
		||||
#: ../src/logdiag.c:106
 | 
			
		||||
msgid "[FILE...]"
 | 
			
		||||
msgstr "[PLIK...]"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:179
 | 
			
		||||
msgid "_About"
 | 
			
		||||
msgstr "_O programie"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:160
 | 
			
		||||
msgid "_Delete"
 | 
			
		||||
msgstr "_Usuń"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:148
 | 
			
		||||
msgid "_Edit"
 | 
			
		||||
msgstr "_Edycja"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:126
 | 
			
		||||
msgid "_File"
 | 
			
		||||
msgstr "_Plik"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:178
 | 
			
		||||
msgid "_Help"
 | 
			
		||||
msgstr "_Pomoc"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:189
 | 
			
		||||
msgid "_Library Pane"
 | 
			
		||||
msgstr "Panel _biblioteki"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:186
 | 
			
		||||
msgid "_Main Toolbar"
 | 
			
		||||
msgstr "_Główny panel narzędzi"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:127
 | 
			
		||||
msgid "_New"
 | 
			
		||||
msgstr "_Nowy"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:174
 | 
			
		||||
msgid "_Normal Size"
 | 
			
		||||
msgstr "_Normalna Wielkość"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:130
 | 
			
		||||
msgid "_Open..."
 | 
			
		||||
msgstr "_Otwórz..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:144
 | 
			
		||||
msgid "_Quit"
 | 
			
		||||
msgstr "_Zakończ"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:152
 | 
			
		||||
msgid "_Redo"
 | 
			
		||||
msgstr "_Powtórz"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:133
 | 
			
		||||
msgid "_Save"
 | 
			
		||||
msgstr "Z_apisz"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:149
 | 
			
		||||
msgid "_Undo"
 | 
			
		||||
msgstr "_Wróć"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:167
 | 
			
		||||
msgid "_View"
 | 
			
		||||
msgstr "_Widok"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:168
 | 
			
		||||
msgid "_Zoom In"
 | 
			
		||||
msgstr "_Przybliżyć"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:983
 | 
			
		||||
msgid "translator-credits"
 | 
			
		||||
msgstr "Robert Svoboda <ravath@gmail.com>"
 | 
			
		||||
 | 
			
		||||
#~ msgid "The file is probably corrupted."
 | 
			
		||||
#~ msgstr "Plik jest prawdopodobnie uszkodzony."
 | 
			
		||||
							
								
								
									
										254
									
								
								po/sk.po
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,254 @@
 | 
			
		||||
# 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-22 22:16+0200\n"
 | 
			
		||||
"PO-Revision-Date: 2018-06-25 04:05+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 2.0.8\n"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:937
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid "%d%%"
 | 
			
		||||
msgstr "%d %%"
 | 
			
		||||
 | 
			
		||||
#: ../src/logdiag.c:147
 | 
			
		||||
msgid "- Schematic editor"
 | 
			
		||||
msgstr "- Editor schém"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:861
 | 
			
		||||
msgid "Close _without Saving"
 | 
			
		||||
msgstr "Zatvoriť _bez uloženia"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:128
 | 
			
		||||
msgid "Create a new diagram"
 | 
			
		||||
msgstr "Vytvorí nový diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:161
 | 
			
		||||
msgid "Delete the contents of the selection"
 | 
			
		||||
msgstr "Odstráni obsah výberu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:354
 | 
			
		||||
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:707
 | 
			
		||||
#, c-format
 | 
			
		||||
msgid "Failed to open file `%s': Invalid contents."
 | 
			
		||||
msgstr "Nepodarilo sa otvoriť súbor \"%s\": Neplatný obsah."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:698
 | 
			
		||||
msgid "Failed to open the file"
 | 
			
		||||
msgstr "Nepodarilo sa otvoriť súbor"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:662
 | 
			
		||||
msgid "Failed to save the diagram"
 | 
			
		||||
msgstr "Nepodarilo sa uložiť diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:859
 | 
			
		||||
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:738
 | 
			
		||||
msgid "Logdiag Diagrams (*.ldd)"
 | 
			
		||||
msgstr "Diagramy logdiag (*.ldd)"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:131
 | 
			
		||||
msgid "Open a diagram"
 | 
			
		||||
msgstr "Otvorí diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:759
 | 
			
		||||
msgid "Open..."
 | 
			
		||||
msgstr "Otvoriť..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:145
 | 
			
		||||
msgid "Quit the application"
 | 
			
		||||
msgstr "Ukončí aplikáciu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:153
 | 
			
		||||
msgid "Redo the last undone action"
 | 
			
		||||
msgstr "Vykoná naposledy vrátenú akciu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:175
 | 
			
		||||
msgid "Reset zoom level back to the default"
 | 
			
		||||
msgstr "Vráti priblíženie na východiskovú hodnotu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:792
 | 
			
		||||
msgid "Save As..."
 | 
			
		||||
msgstr "Uložiť ako..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:136
 | 
			
		||||
msgid "Save _As..."
 | 
			
		||||
msgstr "Uložiť _ako..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:623
 | 
			
		||||
#, 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:755
 | 
			
		||||
#, 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:899
 | 
			
		||||
#, 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:134
 | 
			
		||||
msgid "Save the current diagram"
 | 
			
		||||
msgstr "Uloží aktuálny diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:137
 | 
			
		||||
msgid "Save the current diagram with another name"
 | 
			
		||||
msgstr "Uloží aktuálny diagram pod iným menom"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:163
 | 
			
		||||
msgid "Select _All"
 | 
			
		||||
msgstr "Vybrať _všetko"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:164
 | 
			
		||||
msgid "Select all objects in the diagram"
 | 
			
		||||
msgstr "Vyberie všetky objekty v diagrame"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:192
 | 
			
		||||
msgid "Show _Grid"
 | 
			
		||||
msgstr "Zobraziť _mriežku"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:180
 | 
			
		||||
msgid "Show a dialog about this application"
 | 
			
		||||
msgstr "Zobrazí dialóg o tejto aplikácii"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:193
 | 
			
		||||
msgid "Toggle displaying of the grid"
 | 
			
		||||
msgstr "Prepne zobrazovanie mriežky"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:190
 | 
			
		||||
msgid "Toggle displaying of the library pane"
 | 
			
		||||
msgstr "Prepne zobrazovanie panelu knižnice"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:187
 | 
			
		||||
msgid "Toggle displaying of the main toolbar"
 | 
			
		||||
msgstr "Prepne zobrazovanie hlavného panelu nástrojov"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:665
 | 
			
		||||
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:150
 | 
			
		||||
msgid "Undo the last action"
 | 
			
		||||
msgstr "Vráti poslednú akciu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:591
 | 
			
		||||
msgid "Unsaved Diagram"
 | 
			
		||||
msgstr "Neuložený diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:806
 | 
			
		||||
#, fuzzy
 | 
			
		||||
msgid "Untitled diagram"
 | 
			
		||||
msgstr "Neuložený diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:171
 | 
			
		||||
msgid "Zoom _Out"
 | 
			
		||||
msgstr "_Oddialiť"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:169
 | 
			
		||||
msgid "Zoom into the diagram"
 | 
			
		||||
msgstr "Priblíži diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:172
 | 
			
		||||
msgid "Zoom out of the diagram"
 | 
			
		||||
msgstr "Oddiali diagram"
 | 
			
		||||
 | 
			
		||||
#: ../src/logdiag.c:106
 | 
			
		||||
msgid "[FILE...]"
 | 
			
		||||
msgstr "[SÚBOR...]"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:179
 | 
			
		||||
msgid "_About"
 | 
			
		||||
msgstr "_O programe"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:160
 | 
			
		||||
msgid "_Delete"
 | 
			
		||||
msgstr "_Zmazať"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:148
 | 
			
		||||
msgid "_Edit"
 | 
			
		||||
msgstr "_Úpravy"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:126
 | 
			
		||||
msgid "_File"
 | 
			
		||||
msgstr "_Súbor"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:178
 | 
			
		||||
msgid "_Help"
 | 
			
		||||
msgstr "_Nápoveda"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:189
 | 
			
		||||
msgid "_Library Pane"
 | 
			
		||||
msgstr "Panel _knižnice"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:186
 | 
			
		||||
msgid "_Main Toolbar"
 | 
			
		||||
msgstr "_Hlavný panel nástrojov"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:127
 | 
			
		||||
msgid "_New"
 | 
			
		||||
msgstr "_Nový"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:174
 | 
			
		||||
msgid "_Normal Size"
 | 
			
		||||
msgstr "_Normálna veľkosť"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:130
 | 
			
		||||
msgid "_Open..."
 | 
			
		||||
msgstr "_Otvoriť..."
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:144
 | 
			
		||||
msgid "_Quit"
 | 
			
		||||
msgstr "U_končiť"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:152
 | 
			
		||||
msgid "_Redo"
 | 
			
		||||
msgstr "Z_novu"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:133
 | 
			
		||||
msgid "_Save"
 | 
			
		||||
msgstr "_Uložiť"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:149
 | 
			
		||||
msgid "_Undo"
 | 
			
		||||
msgstr "_Späť"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:167
 | 
			
		||||
msgid "_View"
 | 
			
		||||
msgstr "_Zobrazenie"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:168
 | 
			
		||||
msgid "_Zoom In"
 | 
			
		||||
msgstr "_Priblížiť"
 | 
			
		||||
 | 
			
		||||
#: ../src/ld-window-main.c:983
 | 
			
		||||
msgid "translator-credits"
 | 
			
		||||
msgstr "Miroslav Rigler <itsgoingd@luzer.sk>"
 | 
			
		||||
 | 
			
		||||
#~ msgid "The file is probably corrupted."
 | 
			
		||||
#~ msgstr "Súbor je pravdepodobne poškodený."
 | 
			
		||||
@@ -26,11 +26,17 @@
 | 
			
		||||
			<menuitem action="SelectAll" />
 | 
			
		||||
		</menu>
 | 
			
		||||
		<menu name="ViewMenu" action="ViewMenu">
 | 
			
		||||
			<menuitem action="MainToolbar" />
 | 
			
		||||
			<menuitem action="LibraryPane" />
 | 
			
		||||
			<separator />
 | 
			
		||||
			<menuitem action="ShowGrid" />
 | 
			
		||||
			<separator />
 | 
			
		||||
			<menuitem action="ZoomIn" />
 | 
			
		||||
			<menuitem action="ZoomOut" />
 | 
			
		||||
			<menuitem action="NormalSize" />
 | 
			
		||||
		</menu>
 | 
			
		||||
		<menu name="HelpMenu" action="HelpMenu">
 | 
			
		||||
			<menuitem action="UserGuide" />
 | 
			
		||||
			<menuitem action="About" />
 | 
			
		||||
		</menu>
 | 
			
		||||
	</menubar>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								share/header.bmp
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 25 KiB  | 
							
								
								
									
										159
									
								
								share/header.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,159 @@
 | 
			
		||||
<?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="150"
 | 
			
		||||
   height="57"
 | 
			
		||||
   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>
 | 
			
		||||
  <rect
 | 
			
		||||
     width="150"
 | 
			
		||||
     height="57"
 | 
			
		||||
     x="0"
 | 
			
		||||
     y="-1.3322676e-15"
 | 
			
		||||
     id="rect3078"
 | 
			
		||||
     style="fill:#ffffff;fill-opacity:1;stroke:none" />
 | 
			
		||||
  <g
 | 
			
		||||
     transform="translate(0,-995.36218)"
 | 
			
		||||
     id="layer1">
 | 
			
		||||
    <g
 | 
			
		||||
       transform="matrix(0.33083214,0,0,0.33083214,7.3082845,1004.0193)"
 | 
			
		||||
       id="g3077">
 | 
			
		||||
      <g
 | 
			
		||||
         transform="translate(0,-926.86216)"
 | 
			
		||||
         id="layer1-4"
 | 
			
		||||
         style="fill:none;stroke:#ffffff;stroke-width:22.81488991;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none">
 | 
			
		||||
        <g
 | 
			
		||||
           transform="translate(-10,-60)"
 | 
			
		||||
           id="g3016-5"
 | 
			
		||||
           style="stroke-width:22.81488991">
 | 
			
		||||
          <path
 | 
			
		||||
             d="m 25,108 20,0"
 | 
			
		||||
             transform="translate(0,924.36218)"
 | 
			
		||||
             id="path3008-0"
 | 
			
		||||
             style="stroke-width:22.81488991" />
 | 
			
		||||
          <path
 | 
			
		||||
             d="m 25,88 20,0"
 | 
			
		||||
             transform="translate(0,924.36218)"
 | 
			
		||||
             id="path3010-3"
 | 
			
		||||
             style="stroke-width:22.81488991" />
 | 
			
		||||
          <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-6"
 | 
			
		||||
             style="stroke-width:22.81488991" />
 | 
			
		||||
          <path
 | 
			
		||||
             d="m 90,98 20,0"
 | 
			
		||||
             transform="translate(0,924.36218)"
 | 
			
		||||
             id="path3014-1"
 | 
			
		||||
             style="stroke-width:22.81488991" />
 | 
			
		||||
        </g>
 | 
			
		||||
        <g
 | 
			
		||||
           transform="translate(10,-5.00002)"
 | 
			
		||||
           id="g3016-8-0"
 | 
			
		||||
           style="stroke-width:22.81488991">
 | 
			
		||||
          <path
 | 
			
		||||
             d="m 25,1022.3622 20,0"
 | 
			
		||||
             id="path3010-0-6"
 | 
			
		||||
             style="stroke-width:22.81488991" />
 | 
			
		||||
          <path
 | 
			
		||||
             d="M 45,118 45,78 75,98 z"
 | 
			
		||||
             transform="translate(0,924.36218)"
 | 
			
		||||
             id="path3012-9-3"
 | 
			
		||||
             style="stroke-width:22.81488991" />
 | 
			
		||||
          <path
 | 
			
		||||
             d="m 87.5,1022.3622 17.5,0"
 | 
			
		||||
             id="path3014-6-2"
 | 
			
		||||
             style="stroke-width:22.81488991" />
 | 
			
		||||
          <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-0"
 | 
			
		||||
             style="stroke-width:45.62977982" />
 | 
			
		||||
        </g>
 | 
			
		||||
      </g>
 | 
			
		||||
      <g
 | 
			
		||||
         transform="translate(0,-926.86216)"
 | 
			
		||||
         id="layer1-5"
 | 
			
		||||
         style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:6.33746958;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none">
 | 
			
		||||
        <g
 | 
			
		||||
           transform="translate(-10,-60)"
 | 
			
		||||
           id="g3016"
 | 
			
		||||
           style="stroke-width:6.33746958">
 | 
			
		||||
          <path
 | 
			
		||||
             d="m 25,108 20,0"
 | 
			
		||||
             transform="translate(0,924.36218)"
 | 
			
		||||
             id="path3008"
 | 
			
		||||
             style="stroke-width:6.33746958" />
 | 
			
		||||
          <path
 | 
			
		||||
             d="m 25,88 20,0"
 | 
			
		||||
             transform="translate(0,924.36218)"
 | 
			
		||||
             id="path3010"
 | 
			
		||||
             style="stroke-width:6.33746958" />
 | 
			
		||||
          <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="stroke-width:6.33746958" />
 | 
			
		||||
          <path
 | 
			
		||||
             d="m 90,98 20,0"
 | 
			
		||||
             transform="translate(0,924.36218)"
 | 
			
		||||
             id="path3014"
 | 
			
		||||
             style="stroke-width:6.33746958" />
 | 
			
		||||
        </g>
 | 
			
		||||
        <g
 | 
			
		||||
           transform="translate(10,-5.00002)"
 | 
			
		||||
           id="g3016-8"
 | 
			
		||||
           style="stroke-width:6.33746958">
 | 
			
		||||
          <path
 | 
			
		||||
             d="m 25,1022.3622 20,0"
 | 
			
		||||
             id="path3010-0"
 | 
			
		||||
             style="stroke-width:6.33746958" />
 | 
			
		||||
          <path
 | 
			
		||||
             d="M 45,118 45,78 75,98 z"
 | 
			
		||||
             transform="translate(0,924.36218)"
 | 
			
		||||
             id="path3012-9"
 | 
			
		||||
             style="stroke-width:6.33746958" />
 | 
			
		||||
          <path
 | 
			
		||||
             d="m 87.5,1022.3622 17.5,0"
 | 
			
		||||
             id="path3014-6"
 | 
			
		||||
             style="stroke-width:6.33746958" />
 | 
			
		||||
          <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="stroke-width:12.67493916" />
 | 
			
		||||
        </g>
 | 
			
		||||
      </g>
 | 
			
		||||
    </g>
 | 
			
		||||
    <text
 | 
			
		||||
       x="56.96154"
 | 
			
		||||
       y="1029.7422"
 | 
			
		||||
       id="text3103"
 | 
			
		||||
       xml:space="preserve"
 | 
			
		||||
       style="font-size:22.81624222px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"><tspan
 | 
			
		||||
         x="56.96154"
 | 
			
		||||
         y="1029.7422"
 | 
			
		||||
         id="tspan3105"
 | 
			
		||||
         style="font-size:20px;font-weight:bold">logdiag</tspan></text>
 | 
			
		||||
  </g>
 | 
			
		||||
</svg>
 | 
			
		||||
| 
		 After Width: | Height: | Size: 5.3 KiB  | 
							
								
								
									
										79
									
								
								share/library/Active/bipolar.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,79 @@
 | 
			
		||||
-- Symbol names
 | 
			
		||||
local names_npn =
 | 
			
		||||
{
 | 
			
		||||
	en = "NPN transistor",
 | 
			
		||||
	cs = "Tranzistor NPN",
 | 
			
		||||
	sk = "Tranzistor NPN",
 | 
			
		||||
	pl = "Tranzystor NPN",
 | 
			
		||||
	de = "NPN Transistor"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local names_pnp =
 | 
			
		||||
{
 | 
			
		||||
	en = "PNP transistor",
 | 
			
		||||
	cs = "Tranzistor PNP",
 | 
			
		||||
	sk = "Tranzistor PNP",
 | 
			
		||||
	pl = "Tranzystor PNP",
 | 
			
		||||
	de = "PNP Transistor"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Render area in base units (X1, Y1, X2, Y2)
 | 
			
		||||
local area = {-2, -2, 2, 2}
 | 
			
		||||
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals = {{-2, 0}, {2, 2}, {2, -2}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The terminals
 | 
			
		||||
	cr:move_to (-2, 0)
 | 
			
		||||
	cr:line_to (0, 0)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (0, 0.5)
 | 
			
		||||
	cr:line_to (2, 2)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (0, -0.5)
 | 
			
		||||
	cr:line_to (2, -2)
 | 
			
		||||
 | 
			
		||||
	-- The ohmic connection
 | 
			
		||||
	cr:move_to (0, -1)
 | 
			
		||||
	cr:line_to (0, 1)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local render_npn = function (cr)
 | 
			
		||||
	render (cr)
 | 
			
		||||
 | 
			
		||||
	cr:save ()
 | 
			
		||||
	cr:translate (0, 0.5)
 | 
			
		||||
	cr:rotate (math.atan2 (-2, 1.5))
 | 
			
		||||
 | 
			
		||||
	cr:move_to (-0.4, 0.8)
 | 
			
		||||
	cr:line_to (0, 1.4)
 | 
			
		||||
	cr:line_to (0.4, 0.8)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
	cr:restore ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local render_pnp = function (cr)
 | 
			
		||||
	render (cr)
 | 
			
		||||
 | 
			
		||||
	cr:save ()
 | 
			
		||||
	cr:translate (2, -2)
 | 
			
		||||
	cr:rotate (math.atan2 (2, 1.5))
 | 
			
		||||
 | 
			
		||||
	cr:move_to (-0.4, 1.3)
 | 
			
		||||
	cr:line_to (0, 1.9)
 | 
			
		||||
	cr:line_to (0.4, 1.3)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
	cr:restore ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbols
 | 
			
		||||
logdiag.register ("NPN", names_npn, area, terminals, render_npn)
 | 
			
		||||
logdiag.register ("PNP", names_pnp, area, terminals, render_pnp)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										8
									
								
								share/library/Active/category.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,8 @@
 | 
			
		||||
{
 | 
			
		||||
	"en": "Active",
 | 
			
		||||
	"cs": "Aktivní",
 | 
			
		||||
	"sk": "Aktívne",
 | 
			
		||||
	"pl": "Aktywne",
 | 
			
		||||
	"de": "Aktiv"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										89
									
								
								share/library/Active/igfet.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,89 @@
 | 
			
		||||
-- Symbol names
 | 
			
		||||
local names_n =
 | 
			
		||||
{
 | 
			
		||||
	en = "N-channel IGFET transistor",
 | 
			
		||||
	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 =
 | 
			
		||||
{
 | 
			
		||||
	en = "P-channel IGFET transistor",
 | 
			
		||||
	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)
 | 
			
		||||
local area = {-2, -1.5, 2, 1.5}
 | 
			
		||||
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals_n = {{-2, 1}, {2, 1}, {2, 0}, {2, -1}}
 | 
			
		||||
local terminals_p = {{-2, -1}, {2, 1}, {2, 0}, {2, -1}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The terminals
 | 
			
		||||
	cr:move_to (-0.3, 1)
 | 
			
		||||
	cr:line_to (-0.3, -1)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (0, 1)
 | 
			
		||||
	cr:line_to (2, 1)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (0, 0)
 | 
			
		||||
	cr:line_to (2, 0)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (0, -1)
 | 
			
		||||
	cr:line_to (2, -1)
 | 
			
		||||
 | 
			
		||||
	-- Source, gate, drain
 | 
			
		||||
	cr:move_to (0, -1.5)
 | 
			
		||||
	cr:line_to (0, -0.5)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (0, -0.3)
 | 
			
		||||
	cr:line_to (0, 0.3)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (0, 0.5)
 | 
			
		||||
	cr:line_to (0, 1.5)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local render_n = function (cr)
 | 
			
		||||
	render (cr)
 | 
			
		||||
 | 
			
		||||
	-- The left-side terminal
 | 
			
		||||
	cr:move_to (-2, 1)
 | 
			
		||||
	cr:line_to (-0.3, 1)
 | 
			
		||||
 | 
			
		||||
	-- The arrow
 | 
			
		||||
	cr:move_to (0.9, -0.4)
 | 
			
		||||
	cr:line_to (0.4, 0)
 | 
			
		||||
	cr:line_to (0.9, 0.4)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local render_p = function (cr)
 | 
			
		||||
	render (cr)
 | 
			
		||||
 | 
			
		||||
	-- The left-side terminal
 | 
			
		||||
	cr:move_to (-2, -1)
 | 
			
		||||
	cr:line_to (-0.3, -1)
 | 
			
		||||
 | 
			
		||||
	-- The arrow
 | 
			
		||||
	cr:move_to (0.4, -0.4)
 | 
			
		||||
	cr:line_to (0.9, 0)
 | 
			
		||||
	cr:line_to (0.4, 0.4)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbols
 | 
			
		||||
logdiag.register ("IGFET-N", names_n, area, terminals_n, render_n)
 | 
			
		||||
logdiag.register ("IGFET-P", names_p, area, terminals_p, render_p)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										77
									
								
								share/library/Active/jfet.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,77 @@
 | 
			
		||||
-- Symbol names
 | 
			
		||||
local names_n =
 | 
			
		||||
{
 | 
			
		||||
	en = "N-channel JFET transistor",
 | 
			
		||||
	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 =
 | 
			
		||||
{
 | 
			
		||||
	en = "P-channel JFET transistor",
 | 
			
		||||
	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)
 | 
			
		||||
local area = {-2, -1.5, 2, 1.5}
 | 
			
		||||
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals_n = {{-2, 1}, {2, 1}, {2, -1}}
 | 
			
		||||
local terminals_p = {{-2, -1}, {2, 1}, {2, -1}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The terminals
 | 
			
		||||
	cr:move_to (0, 1)
 | 
			
		||||
	cr:line_to (2, 1)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (0, -1)
 | 
			
		||||
	cr:line_to (2, -1)
 | 
			
		||||
 | 
			
		||||
	-- The ohmic connection
 | 
			
		||||
	cr:move_to (0, -1.5)
 | 
			
		||||
	cr:line_to (0, 1.5)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local render_n = function (cr)
 | 
			
		||||
	render (cr)
 | 
			
		||||
 | 
			
		||||
	-- The left-side terminal
 | 
			
		||||
	cr:move_to (-2, 1)
 | 
			
		||||
	cr:line_to (0, 1)
 | 
			
		||||
 | 
			
		||||
	-- The arrow
 | 
			
		||||
	cr:move_to (-1, 0.6)
 | 
			
		||||
	cr:line_to (-0.5, 1)
 | 
			
		||||
	cr:line_to (-1, 1.4)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local render_p = function (cr)
 | 
			
		||||
	render (cr)
 | 
			
		||||
 | 
			
		||||
	-- The left-side terminal
 | 
			
		||||
	cr:move_to (-2, -1)
 | 
			
		||||
	cr:line_to (0, -1)
 | 
			
		||||
 | 
			
		||||
	-- The arrow
 | 
			
		||||
	cr:move_to (-0.4, -0.6)
 | 
			
		||||
	cr:line_to (-1, -1)
 | 
			
		||||
	cr:line_to (-0.4, -1.4)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbols
 | 
			
		||||
logdiag.register ("JFET-N", names_n, area, terminals_n, render_n)
 | 
			
		||||
logdiag.register ("JFET-P", names_p, area, terminals_p, render_p)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,38 +1,39 @@
 | 
			
		||||
-- Symbol name
 | 
			
		||||
names =
 | 
			
		||||
local names =
 | 
			
		||||
{
 | 
			
		||||
	en = "AND",
 | 
			
		||||
	cs = "AND"
 | 
			
		||||
	cs = "AND",
 | 
			
		||||
	sk = "AND",
 | 
			
		||||
	pl = "AND",
 | 
			
		||||
	de = "UND"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Render area in base units (X1, Y1, X2, Y2)
 | 
			
		||||
area = {-4, -2, 5, 2}
 | 
			
		||||
local area = {-4, -2, 5, 2}
 | 
			
		||||
 | 
			
		||||
-- Terminals
 | 
			
		||||
terminals = {{-4, -1}, {-4, 1}, {5, 0}}
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals = {{-4, -1}, {-4, 1}, {5, 0}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
render = function (cr)
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The main shape
 | 
			
		||||
	cr.move_to (-2, -2)
 | 
			
		||||
	cr.line_to (1, -2)
 | 
			
		||||
	cr.arc (1, 0, 2, math.pi * 1.5, math.pi * 0.5)
 | 
			
		||||
	cr.line_to (-2, 2)
 | 
			
		||||
	cr.close_path ()
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (-2, -2)
 | 
			
		||||
	cr:line_to (1, -2)
 | 
			
		||||
	cr:arc (1, 0, 2, math.pi * 1.5, math.pi * 0.5)
 | 
			
		||||
	cr:line_to (-2, 2)
 | 
			
		||||
	cr:close_path ()
 | 
			
		||||
 | 
			
		||||
	-- The contacts
 | 
			
		||||
	cr.move_to (-4, -1)
 | 
			
		||||
	cr.line_to (-2, -1)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	-- The terminals
 | 
			
		||||
	cr:move_to (-4, -1)
 | 
			
		||||
	cr:line_to (-2, -1)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (-4, 1)
 | 
			
		||||
	cr.line_to (-2, 1)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (-4, 1)
 | 
			
		||||
	cr:line_to (-2, 1)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (3, 0)
 | 
			
		||||
	cr.line_to (5, 0)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (3, 0)
 | 
			
		||||
	cr:line_to (5, 0)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbol
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
	"en": "Logical",
 | 
			
		||||
	"cs": "Logické"
 | 
			
		||||
	"cs": "Logické",
 | 
			
		||||
	"sk": "Logické",
 | 
			
		||||
	"pl": "Logiczne"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,76 +0,0 @@
 | 
			
		||||
<?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>
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 2.9 KiB  | 
@@ -1,38 +1,39 @@
 | 
			
		||||
-- Symbol name
 | 
			
		||||
names =
 | 
			
		||||
local names =
 | 
			
		||||
{
 | 
			
		||||
	en = "NOT",
 | 
			
		||||
	cs = "NOT"
 | 
			
		||||
	cs = "NOT",
 | 
			
		||||
	sk = "NOT",
 | 
			
		||||
	pl = "NOT",
 | 
			
		||||
	de = "NICHT"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Render area in base units (X1, Y1, X2, Y2)
 | 
			
		||||
area = {-4, -2, 4, 2}
 | 
			
		||||
local area = {-4, -2, 4, 2}
 | 
			
		||||
 | 
			
		||||
-- Terminals
 | 
			
		||||
terminals = {{-4, 0}, {4, 0}}
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals = {{-4, 0}, {4, 0}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
render = function (cr)
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The triangle
 | 
			
		||||
	cr.move_to (-2, -2)
 | 
			
		||||
	cr.line_to (2, 0)
 | 
			
		||||
	cr.line_to (-2, 2)
 | 
			
		||||
	cr.close_path ()
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (-2, -2)
 | 
			
		||||
	cr:line_to (2, 0)
 | 
			
		||||
	cr:line_to (-2, 2)
 | 
			
		||||
	cr:close_path ()
 | 
			
		||||
 | 
			
		||||
	-- The circle
 | 
			
		||||
	cr.new_sub_path ()
 | 
			
		||||
	cr.arc (2.25, 0, 0.25, 0, 2 * math.pi)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:new_sub_path ()
 | 
			
		||||
	cr:arc (2.25, 0, 0.25, 0, 2 * math.pi)
 | 
			
		||||
 | 
			
		||||
	-- The contacts
 | 
			
		||||
	cr.move_to (-4, 0)
 | 
			
		||||
	cr.line_to (-2, 0)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	-- The terminals
 | 
			
		||||
	cr:move_to (-4, 0)
 | 
			
		||||
	cr:line_to (-2, 0)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (2.5, 0)
 | 
			
		||||
	cr.line_to (4, 0)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (2.5, 0)
 | 
			
		||||
	cr:line_to (4, 0)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbol
 | 
			
		||||
 
 | 
			
		||||
@@ -1,52 +1,54 @@
 | 
			
		||||
-- Symbol name
 | 
			
		||||
names =
 | 
			
		||||
local names =
 | 
			
		||||
{
 | 
			
		||||
	en = "OR",
 | 
			
		||||
	cs = "OR"
 | 
			
		||||
	cs = "OR",
 | 
			
		||||
	sk = "OR",
 | 
			
		||||
	pl = "OR",
 | 
			
		||||
	de = "ODER"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Render area in base units (X1, Y1, X2, Y2)
 | 
			
		||||
area = {-4, -2, 5, 2}
 | 
			
		||||
local area = {-4, -2, 5, 2}
 | 
			
		||||
 | 
			
		||||
-- Terminals
 | 
			
		||||
terminals = {{-4, -1}, {-4, 1}, {5, 0}}
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals = {{-4, -1}, {-4, 1}, {5, 0}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
render = function (cr)
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The main shape
 | 
			
		||||
	cr.move_to (-2, -2)
 | 
			
		||||
	cr.line_to (0, -2)
 | 
			
		||||
	cr.curve_to (2, -2, 3, 0, 3, 0)
 | 
			
		||||
	cr.curve_to (3, 0, 2, 2, 0, 2)
 | 
			
		||||
	cr.line_to (-2, 2)
 | 
			
		||||
	cr.curve_to (-1, 1, -1, -1, -2, -2)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (-2, -2)
 | 
			
		||||
	cr:line_to (0, -2)
 | 
			
		||||
	cr:curve_to (2, -2, 3, 0, 3, 0)
 | 
			
		||||
	cr:curve_to (3, 0, 2, 2, 0, 2)
 | 
			
		||||
	cr:line_to (-2, 2)
 | 
			
		||||
	cr:curve_to (-1, 1, -1, -1, -2, -2)
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
 | 
			
		||||
	-- The contacts
 | 
			
		||||
	cr.save ()
 | 
			
		||||
	-- The terminals
 | 
			
		||||
	cr:save ()
 | 
			
		||||
 | 
			
		||||
	-- Crop the contacts according to
 | 
			
		||||
	-- the left side of the main shape
 | 
			
		||||
	cr.move_to (-4, 2)
 | 
			
		||||
	cr.line_to (-2, 2)
 | 
			
		||||
	cr.curve_to (-1, 1, -1, -1, -2, -2)
 | 
			
		||||
	cr.line_to (-4, -2)
 | 
			
		||||
	cr.close_path ()
 | 
			
		||||
	cr.clip ()
 | 
			
		||||
	cr:move_to (-4, 2)
 | 
			
		||||
	cr:line_to (-2, 2)
 | 
			
		||||
	cr:curve_to (-1, 1, -1, -1, -2, -2)
 | 
			
		||||
	cr:line_to (-4, -2)
 | 
			
		||||
	cr:close_path ()
 | 
			
		||||
	cr:clip ()
 | 
			
		||||
 | 
			
		||||
	cr.move_to (-4, -1)
 | 
			
		||||
	cr.line_to (-1, -1)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (-4, -1)
 | 
			
		||||
	cr:line_to (-1, -1)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (-4, 1)
 | 
			
		||||
	cr.line_to (-1, 1)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (-4, 1)
 | 
			
		||||
	cr:line_to (-1, 1)
 | 
			
		||||
 | 
			
		||||
	cr.restore ()
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
	cr:restore ()
 | 
			
		||||
 | 
			
		||||
	cr.move_to (3, 0)
 | 
			
		||||
	cr.line_to (5, 0)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (3, 0)
 | 
			
		||||
	cr:line_to (5, 0)
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbol
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,8 @@
 | 
			
		||||
{
 | 
			
		||||
	"en": "Miscellaneous",
 | 
			
		||||
	"cs": "Smíšené"
 | 
			
		||||
	"cs": "Smíšené",
 | 
			
		||||
	"sk": "Zmiešané",
 | 
			
		||||
	"pl": "Różne",
 | 
			
		||||
	"de": "Diverse"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										39
									
								
								share/library/Misc/cell.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,39 @@
 | 
			
		||||
-- Symbol name
 | 
			
		||||
local names =
 | 
			
		||||
{
 | 
			
		||||
	en = "Cell",
 | 
			
		||||
	cs = "Článek",
 | 
			
		||||
	sk = "Článok",
 | 
			
		||||
	pl = "Ogniwo",
 | 
			
		||||
	de = "Zelle"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Render area in base units (X1, Y1, X2, Y2)
 | 
			
		||||
local area = {-1, -2, 1, 2}
 | 
			
		||||
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals = {{-1, 0}, {1, 0}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The vertical lines
 | 
			
		||||
	cr:move_to (-0.2, -1)
 | 
			
		||||
	cr:line_to (-0.2, 1)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (0.2, -2)
 | 
			
		||||
	cr:line_to (0.2, 2)
 | 
			
		||||
 | 
			
		||||
	-- The terminals
 | 
			
		||||
	cr:move_to (-1, 0)
 | 
			
		||||
	cr:line_to (-0.2, 0)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (0.2, 0)
 | 
			
		||||
	cr:line_to (1, 0)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbol
 | 
			
		||||
logdiag.register ("Cell", names, area, terminals, render)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,33 +1,36 @@
 | 
			
		||||
-- Symbol name
 | 
			
		||||
names =
 | 
			
		||||
local names =
 | 
			
		||||
{
 | 
			
		||||
	en = "Ground",
 | 
			
		||||
	cs = "Zem"
 | 
			
		||||
	cs = "Zem",
 | 
			
		||||
	sk = "Uzemnenie",
 | 
			
		||||
	pl = "Ziemia",
 | 
			
		||||
	de = "Masse"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Render area in base units (X1, Y1, X2, Y2)
 | 
			
		||||
area = {-1, -1, 1, 2}
 | 
			
		||||
local area = {-1, -1, 1, 2}
 | 
			
		||||
 | 
			
		||||
-- Terminals
 | 
			
		||||
terminals = {{0, -1}}
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals = {{0, -1}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
render = function (cr)
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The vertical line
 | 
			
		||||
	cr.move_to (0, -1)
 | 
			
		||||
	cr.line_to (0, 0.5)
 | 
			
		||||
	cr:move_to (0, -1)
 | 
			
		||||
	cr:line_to (0, 0.5)
 | 
			
		||||
 | 
			
		||||
	-- The horizontal lines
 | 
			
		||||
	cr.move_to (-1, 0.5)
 | 
			
		||||
	cr.line_to (1, 0.5)
 | 
			
		||||
	cr:move_to (-1, 0.5)
 | 
			
		||||
	cr:line_to (1, 0.5)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (-0.75, 1.1)
 | 
			
		||||
	cr.line_to (0.75, 1.1)
 | 
			
		||||
	cr:move_to (-0.75, 1.1)
 | 
			
		||||
	cr:line_to (0.75, 1.1)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (-0.5, 1.7)
 | 
			
		||||
	cr.line_to (0.5, 1.7)
 | 
			
		||||
	cr:move_to (-0.5, 1.7)
 | 
			
		||||
	cr:line_to (0.5, 1.7)
 | 
			
		||||
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbol
 | 
			
		||||
 
 | 
			
		||||
@@ -1,78 +0,0 @@
 | 
			
		||||
<?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>
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 2.8 KiB  | 
							
								
								
									
										27
									
								
								share/library/Misc/junction.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,27 @@
 | 
			
		||||
-- Symbol name
 | 
			
		||||
local names =
 | 
			
		||||
{
 | 
			
		||||
	en = "Junction",
 | 
			
		||||
	cs = "Spoj",
 | 
			
		||||
	sk = "Spoj",
 | 
			
		||||
	pl = "Złącze",
 | 
			
		||||
	de = "Anschluss"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- 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 = function (cr)
 | 
			
		||||
	-- The disk
 | 
			
		||||
	cr:arc (0, 0, 0.3, 0, math.pi * 2)
 | 
			
		||||
	cr:fill ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbol
 | 
			
		||||
logdiag.register ("Junction", names, area, terminals, render)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,41 +1,45 @@
 | 
			
		||||
-- Symbol name
 | 
			
		||||
names =
 | 
			
		||||
local names =
 | 
			
		||||
{
 | 
			
		||||
	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)
 | 
			
		||||
area = {-2, -1, 2, 1}
 | 
			
		||||
local area = {-2, -1, 2, 1}
 | 
			
		||||
 | 
			
		||||
-- Terminals
 | 
			
		||||
terminals = {{-2, 0}, {2, 0}}
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals = {{-2, 0}, {2, 0}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
render = function (cr)
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The circle
 | 
			
		||||
	cr.save ()
 | 
			
		||||
	cr:save ()
 | 
			
		||||
 | 
			
		||||
	cr.arc (0, 0, 1, 0, 2 * math.pi)
 | 
			
		||||
	cr.stroke_preserve ()
 | 
			
		||||
	cr.clip ()
 | 
			
		||||
	cr:arc (0, 0, 1, 0, 2 * math.pi)
 | 
			
		||||
	cr:stroke_preserve ()
 | 
			
		||||
	cr:clip ()
 | 
			
		||||
 | 
			
		||||
	cr.move_to (-1, -1)
 | 
			
		||||
	cr.line_to (1, 1)
 | 
			
		||||
	cr:move_to (-1, -1)
 | 
			
		||||
	cr:line_to (1, 1)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (1, -1)
 | 
			
		||||
	cr.line_to (-1, 1)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (1, -1)
 | 
			
		||||
	cr:line_to (-1, 1)
 | 
			
		||||
 | 
			
		||||
	cr.restore ()
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
	cr:restore ()
 | 
			
		||||
 | 
			
		||||
	-- The contacts
 | 
			
		||||
	cr.move_to (-2, 0)
 | 
			
		||||
	cr.line_to (-1, 0)
 | 
			
		||||
	-- The terminals
 | 
			
		||||
	cr:move_to (-2, 0)
 | 
			
		||||
	cr:line_to (-1, 0)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (1, 0)
 | 
			
		||||
	cr.line_to (2, 0)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (1, 0)
 | 
			
		||||
	cr:line_to (2, 0)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbol
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										84
									
								
								share/library/Misc/meters.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,84 @@
 | 
			
		||||
-- Symbol names
 | 
			
		||||
local names_A =
 | 
			
		||||
{
 | 
			
		||||
	en = "Ammeter",
 | 
			
		||||
	cs = "Ampérmetr",
 | 
			
		||||
	sk = "Ampérmeter",
 | 
			
		||||
	pl = "Amperomierz",
 | 
			
		||||
	de = "Ampermeter"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local names_V =
 | 
			
		||||
{
 | 
			
		||||
	en = "Voltmeter",
 | 
			
		||||
	cs = "Voltmetr",
 | 
			
		||||
	sk = "Voltmeter",
 | 
			
		||||
	pl = "Woltomierz",
 | 
			
		||||
	de = "Voltmeter"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local names_ohm =
 | 
			
		||||
{
 | 
			
		||||
	en = "Ohmmeter",
 | 
			
		||||
	cs = "Ohmmetr",
 | 
			
		||||
	sk = "Ohmmeter",
 | 
			
		||||
	pl = "Omomierz",
 | 
			
		||||
	de = "Ohmmeter"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Render area in base units (X1, Y1, X2, Y2)
 | 
			
		||||
local area = {-2, -2, 2, 2}
 | 
			
		||||
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals = {{-2, 0}, {2, 0}, {0, -2}, {0, 2}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
local render_A = function (cr)
 | 
			
		||||
	-- The circle
 | 
			
		||||
	cr:arc (0, 0, 2, 0, math.pi * 2)
 | 
			
		||||
 | 
			
		||||
	-- The letter A
 | 
			
		||||
	cr:move_to (-0.4, 0.5)
 | 
			
		||||
	cr:line_to (0, -0.5)
 | 
			
		||||
	cr:line_to (0.4, 0.5)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (-0.3, 0.25)
 | 
			
		||||
	cr:line_to (0.3, 0.25)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local render_V = function (cr)
 | 
			
		||||
	-- The circle
 | 
			
		||||
	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
 | 
			
		||||
 | 
			
		||||
local render_ohm = function (cr)
 | 
			
		||||
	-- The circle
 | 
			
		||||
	cr:arc (0, 0, 2, 0, math.pi * 2)
 | 
			
		||||
 | 
			
		||||
	-- The capital letter omega
 | 
			
		||||
	cr:move_to (-0.5, 0.5)
 | 
			
		||||
	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
 | 
			
		||||
 | 
			
		||||
-- Register the symbols
 | 
			
		||||
logdiag.register ("Ammeter",   names_A,   area, terminals, render_A)
 | 
			
		||||
logdiag.register ("Voltmeter", names_V,   area, terminals, render_V)
 | 
			
		||||
logdiag.register ("Ohmmeter",  names_ohm, area, terminals, render_ohm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,36 +0,0 @@
 | 
			
		||||
-- Symbol name
 | 
			
		||||
names =
 | 
			
		||||
{
 | 
			
		||||
	en = "Power source",
 | 
			
		||||
	cs = "Zdroj napětí"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Render area in base units (X1, Y1, X2, Y2)
 | 
			
		||||
area = {-1, -2, 1, 2}
 | 
			
		||||
 | 
			
		||||
-- Terminals
 | 
			
		||||
terminals = {{-1, 0}, {1, 0}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
render = function (cr)
 | 
			
		||||
	-- The vertical lines
 | 
			
		||||
	cr.move_to (-0.2, -1)
 | 
			
		||||
	cr.line_to (-0.2, 1)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (0.2, -2)
 | 
			
		||||
	cr.line_to (0.2, 2)
 | 
			
		||||
 | 
			
		||||
	-- The contacts
 | 
			
		||||
	cr.move_to (-1, 0)
 | 
			
		||||
	cr.line_to (-0.2, 0)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (0.2, 0)
 | 
			
		||||
	cr.line_to (1, 0)
 | 
			
		||||
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbol
 | 
			
		||||
logdiag.register ("PowerSource", names, area, terminals, render)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										50
									
								
								share/library/Misc/signs.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,50 @@
 | 
			
		||||
-- 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)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,33 +1,36 @@
 | 
			
		||||
-- Symbol name
 | 
			
		||||
names =
 | 
			
		||||
local names =
 | 
			
		||||
{
 | 
			
		||||
	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)
 | 
			
		||||
area = {-2, -1.5, 2, 0}
 | 
			
		||||
local area = {-2, -1.5, 2, 0}
 | 
			
		||||
 | 
			
		||||
-- Terminals
 | 
			
		||||
terminals = {{-2, 0}, {2, 0}}
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals = {{-2, 0}, {2, 0}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
render_normal = function (cr)
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The switch contact
 | 
			
		||||
	cr.move_to (1.3, -1.3)
 | 
			
		||||
	cr.line_to (-1, 0)
 | 
			
		||||
	cr:move_to (1.3, -1.3)
 | 
			
		||||
	cr:line_to (-1, 0)
 | 
			
		||||
 | 
			
		||||
	-- The contacts
 | 
			
		||||
	cr.move_to (-2, 0)
 | 
			
		||||
	cr.line_to (-1, 0)
 | 
			
		||||
	-- The terminals
 | 
			
		||||
	cr:move_to (-2, 0)
 | 
			
		||||
	cr:line_to (-1, 0)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (1, 0)
 | 
			
		||||
	cr.line_to (2, 0)
 | 
			
		||||
	cr:move_to (1, 0)
 | 
			
		||||
	cr:line_to (2, 0)
 | 
			
		||||
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbol
 | 
			
		||||
logdiag.register ("Switch", names, area, terminals, render_normal)
 | 
			
		||||
logdiag.register ("Switch", names, area, terminals, render)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								share/library/Misc/terminal.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,32 @@
 | 
			
		||||
-- Symbol name
 | 
			
		||||
local names =
 | 
			
		||||
{
 | 
			
		||||
	en = "Terminal",
 | 
			
		||||
	cs = "Terminál",
 | 
			
		||||
	sk = "Terminál",
 | 
			
		||||
	pl = "Terminał",
 | 
			
		||||
	de = "Terminal"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Render area in base units (X1, Y1, X2, Y2)
 | 
			
		||||
local area = {-1, -0.5, 0.5, 0.5}
 | 
			
		||||
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals = {{-1, 0}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The circle
 | 
			
		||||
	cr:arc (0, 0, 0.3, 0, math.pi * 2)
 | 
			
		||||
 | 
			
		||||
	-- The contact
 | 
			
		||||
	cr:move_to (-1, 0)
 | 
			
		||||
	cr:line_to (-0.3, 0)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbol
 | 
			
		||||
logdiag.register ("Terminal", names, area, terminals, render)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										64
									
								
								share/library/Misc/voltage-source.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,64 @@
 | 
			
		||||
-- Symbol names
 | 
			
		||||
local names_ac =
 | 
			
		||||
{
 | 
			
		||||
	en = "AC voltage source",
 | 
			
		||||
	cs = "Střídavý zdroj napětí",
 | 
			
		||||
	sk = "Striedavý zdroj napätia",
 | 
			
		||||
	pl = "Źródło prądu zmiennego",
 | 
			
		||||
	de = "Wechselstromquelle"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local names_dc =
 | 
			
		||||
{
 | 
			
		||||
	en = "DC voltage source",
 | 
			
		||||
	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)
 | 
			
		||||
local area = {-2, -2, 2, 2}
 | 
			
		||||
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals = {{-2, 0}, {2, 0}, {0, -2}, {0, 2}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The circle
 | 
			
		||||
	cr:arc (0, 0, 2, 0, math.pi * 2)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local render_ac = function (cr)
 | 
			
		||||
	render (cr)
 | 
			
		||||
 | 
			
		||||
	-- The AC symbol
 | 
			
		||||
	cr:move_to (-1, 0.25)
 | 
			
		||||
	cr:curve_to (-0.4, -1.5, 0.4, 1.5, 1, -0.25)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local render_dc = function (cr)
 | 
			
		||||
	render (cr)
 | 
			
		||||
 | 
			
		||||
	-- The DC symbol
 | 
			
		||||
	cr:move_to (-1, -0.25)
 | 
			
		||||
	cr:line_to (1, -0.25)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (-1, 0.25)
 | 
			
		||||
	cr:line_to (-0.2, 0.25)
 | 
			
		||||
 | 
			
		||||
	cr:move_to (0.2, 0.25)
 | 
			
		||||
	cr:line_to (1, 0.25)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbols
 | 
			
		||||
logdiag.register ("ACSource", names_ac, area, terminals, render_ac)
 | 
			
		||||
logdiag.register ("DCSource", names_dc, area, terminals, render_dc)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,35 +1,36 @@
 | 
			
		||||
-- Symbol name
 | 
			
		||||
names =
 | 
			
		||||
local names =
 | 
			
		||||
{
 | 
			
		||||
	en = "Capacitor",
 | 
			
		||||
	cs = "Kondenzátor"
 | 
			
		||||
	cs = "Kondenzátor",
 | 
			
		||||
	sk = "Kondenzátor",
 | 
			
		||||
	pl = "Kondensator",
 | 
			
		||||
	de = "Kondensator"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
-- Render area in base units (X1, Y1, X2, Y2)
 | 
			
		||||
area = {-2, -1, 2, 1}
 | 
			
		||||
local area = {-2, -1, 2, 1}
 | 
			
		||||
 | 
			
		||||
-- Terminals
 | 
			
		||||
terminals = {{-2, 0}, {2, 0}}
 | 
			
		||||
-- Terminal points
 | 
			
		||||
local terminals = {{-2, 0}, {2, 0}}
 | 
			
		||||
 | 
			
		||||
-- Rendering
 | 
			
		||||
render = function (cr)
 | 
			
		||||
local render = function (cr)
 | 
			
		||||
	-- The vertical lines
 | 
			
		||||
	cr.move_to (-0.2, -1)
 | 
			
		||||
	cr.line_to (-0.2, 1)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (-0.2, -1)
 | 
			
		||||
	cr:line_to (-0.2, 1)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (0.2, -1)
 | 
			
		||||
	cr.line_to (0.2, 1)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (0.2, -1)
 | 
			
		||||
	cr:line_to (0.2, 1)
 | 
			
		||||
 | 
			
		||||
	-- The contacts
 | 
			
		||||
	cr.move_to (-2, 0)
 | 
			
		||||
	cr.line_to (-0.2, 0)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	-- The terminals
 | 
			
		||||
	cr:move_to (-2, 0)
 | 
			
		||||
	cr:line_to (-0.2, 0)
 | 
			
		||||
 | 
			
		||||
	cr.move_to (0.2, 0)
 | 
			
		||||
	cr.line_to (2, 0)
 | 
			
		||||
	cr.stroke ()
 | 
			
		||||
	cr:move_to (0.2, 0)
 | 
			
		||||
	cr:line_to (2, 0)
 | 
			
		||||
 | 
			
		||||
	cr:stroke ()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Register the symbol
 | 
			
		||||
 
 | 
			
		||||