Permalink
Browse files

Initial release

  • Loading branch information...
0 parents commit 0c304192cdd1d3f559132b831e1be7f852e22b0c @SokoloffA SokoloffA committed Jan 16, 2013
Showing with 9,330 additions and 0 deletions.
  1. +17 −0 .gitignore
  2. +16 −0 CMakeLists.txt
  3. +13 −0 cups/CMakeLists.txt
  4. +88 −0 cups/booklet
  5. +121 −0 gui/CMakeLists.txt
  6. +103 −0 gui/cmake/FindGhostscript.cmake
  7. +69 −0 gui/dbus.cpp
  8. +53 −0 gui/dbus.h
  9. BIN gui/images/go-first-view.png
  10. BIN gui/images/go-last-view.png
  11. BIN gui/images/go-next-view.png
  12. BIN gui/images/go-previous-view.png
  13. BIN gui/images/printer.png
  14. +403 −0 gui/kernel/printer.cpp
  15. +113 −0 gui/kernel/printer.h
  16. +39 −0 gui/kernel/psconstants.h
  17. +543 −0 gui/kernel/psengine.cpp
  18. +96 −0 gui/kernel/psengine.h
  19. +269 −0 gui/kernel/psfile.cpp
  20. +119 −0 gui/kernel/psfile.h
  21. +334 −0 gui/kernel/psproject.cpp
  22. +168 −0 gui/kernel/psproject.h
  23. +195 −0 gui/kernel/pssheet.cpp
  24. +130 −0 gui/kernel/pssheet.h
  25. +169 −0 gui/main.cpp
  26. +512 −0 gui/mainwindow.cpp
  27. +98 −0 gui/mainwindow.h
  28. +280 −0 gui/mainwindow.ui
  29. +311 −0 gui/printersettings/printersettings.cpp
  30. +73 −0 gui/printersettings/printersettings.h
  31. +176 −0 gui/printersettings/printersettings.ui
  32. +421 −0 gui/psrender.cpp
  33. +66 −0 gui/psrender.h
  34. +164 −0 gui/psview.cpp
  35. +69 −0 gui/psview.h
  36. +9 −0 gui/resource.qrc
  37. +220 −0 gui/settings.cpp
  38. +74 −0 gui/settings.h
  39. +2,391 −0 gui/third-party/libspectre/ps.c
  40. +244 −0 gui/third-party/libspectre/ps.h
  41. +48 −0 gui/third-party/libspectre/spectre-macros.h
  42. +381 −0 gui/third-party/libspectre/spectre-utils.c
  43. +139 −0 gui/third-party/libspectre/spectre-utils.h
  44. +208 −0 gui/translations/booklet_ru.ts
  45. +4 −0 gui/translations/update.sh
  46. +212 −0 gui/widgets.cpp
  47. +101 −0 gui/widgets.h
  48. +71 −0 scripts/checkLicense.sh
@@ -0,0 +1,17 @@
+moc_*.cxx
+qrc_*.cxx
+cmake_install.cmake
+cmake_uninstall.cmake
+Makefile
+CMakeFiles
+CMakeCache.txt
+CPackConfig.cmake
+CPackSourceConfig.cmake
+lib*.so
+lib*.so.*
+ui_*.h
+*.qm
+*~
+*.autosave
+CMakeLists.txt.user*
+/build
@@ -0,0 +1,16 @@
+cmake_minimum_required( VERSION 2.6 )
+
+project(booklet)
+
+set(GUI_DIR ${CMAKE_INSTALL_PREFIX}/lib/booklet)
+add_definitions(-DGUI_DIR=\"${GUI_DIR}\")
+
+set(GUI_PROGRAM ${GUI_DIR}/booklet)
+add_definitions(-DGUI_PROGRAM=\"${GUI_PROGRAM}\")
+
+set(MY_CUPS_URI "booklet:/")
+add_definitions(-DMY_CUPS_URI=\"${MY_CUPS_URI}\")
+
+add_subdirectory(cups)
+add_subdirectory(gui)
+
@@ -0,0 +1,13 @@
+cmake_minimum_required( VERSION 2.6 )
+
+project(bokletCups)
+
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/booklet
+ ${CMAKE_CURRENT_BINARY_DIR}/booklet
+ @ONLY)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/booklet
+ DESTINATION /usr/lib/cups/backend
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+)
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+TMP_DIR="/tmp"
+
+CUPS_BACKEND_OK=0
+CUPS_BACKEND_FAILED=1
+
+# Have debug info in /var/log/cups/error_log:
+#set -x
+
+# Output "device discovery" information on stdout:
+if test "$#" = "0"; then
+ echo 'file @MY_CUPS_URI@ "Booklet Printer" "Booklet" "MFG:Generic;MDL:Booklet Printer;DES:Booklet Printer;CLS:PRINTER;CMD:POSTSCRIPT;"'
+ exit 0
+fi
+
+jobID=$1
+user=$2
+title=$3
+count=$4
+options=$5
+psFile=$6
+
+if [ -z ${psFile} ]; then
+ psFile=${TMP_DIR}/brint_in_file-${jobID}.ps
+ cat - > ${psFile}
+fi
+
+
+uid=$(id -u $user)
+
+if [ "${uid}" == "" ]; then
+ echo "ERROR: Can't found UID for user '$user'" >&2
+ exit $CUPS_BACKEND_FAILED
+fi
+
+
+echo "DEBUG: User $user" >&2
+echo "DEBUG: Uid $uid" >&2
+
+oldIfs=$IFS
+IFS=$(echo -en "\n")
+while read line; do
+ IFS="$oldIfs='"
+ read key value <<< $line;
+
+ case $key in
+ Session*)
+ if [ "$sesUid" = "$uid" -a "$sesActive" = "TRUE" -a "$sesDisplay" != "" ]; then
+ echo "DEBUG: Session=$line" >&2
+ echo "DEBUG: DISPLAY=$sesDisplay" >&2
+
+ xDisplay=$sesDisplay
+ break;
+ fi
+
+ unset sesUid
+ unset sesActive
+ unset sesADisplay
+ ;;
+
+ unix-user)
+ sesUid=$value
+ ;;
+
+ active)
+ sesActive=$value
+ ;;
+
+ x11-display)
+ sesDisplay=$value
+ ;;
+ esac
+done <<< $(ck-list-sessions | tac );
+
+
+if [ "${xDisplay}" == "" ]; then
+ echo "ERROR: Can't found session for user '$user' (UID: $uid)" >&2
+ exit $CUPS_BACKEND_FAILED
+fi
+
+chown ${user} ${psFile}
+export DISPLAY=${xDisplay}
+su -c "@GUI_PROGRAM@ -t \"$title\" -n $count $psFile" $user 0<&- &>/tmp/booklet-${user}.log &
+
+exit $CUPS_BACKEND_OK
+
+
@@ -0,0 +1,121 @@
+cmake_minimum_required( VERSION 2.6 )
+
+project(bookletGui)
+
+set(HEADERS
+ kernel/psconstants.h
+ kernel/psfile.h
+ kernel/psproject.h
+ kernel/pssheet.h
+ kernel/psengine.h
+ kernel/printer.h
+ third-party/libspectre/ps.h
+ third-party/libspectre/spectre-utils.h
+ mainwindow.h
+ settings.h
+ widgets.h
+
+ dbus.h
+ printersettings/printersettings.h
+ psrender.h
+ psview.h
+)
+
+set(SOURCES
+ main.cpp
+ kernel/psfile.cpp
+ kernel/psproject.cpp
+ kernel/pssheet.cpp
+ kernel/psengine.cpp
+ kernel/printer.cpp
+ third-party/libspectre/ps.c
+ third-party/libspectre/spectre-utils.c
+ mainwindow.cpp
+ settings.cpp
+ widgets.cpp
+ dbus.cpp
+ printersettings/printersettings.cpp
+ psrender.cpp
+ psview.cpp
+)
+
+set (MOCS
+ kernel/psfile.h
+ kernel/psproject.h
+ mainwindow.h
+ widgets.h
+ dbus.h
+ printersettings/printersettings.h
+ psrender.h
+ psview.h
+)
+
+set(LIBRARIES
+)
+
+set(QT_USE_QTDBUS 1)
+
+set(UI_FILES
+ mainwindow.ui
+ printersettings/printersettings.ui
+)
+
+# QRC files .................
+set(RESOURCES
+ resource.qrc
+)
+
+# add translations ...
+file (GLOB TS_FILES
+ translations/*.ts
+)
+
+set(DATA_DIR
+ ${CMAKE_INSTALL_PREFIX}/share/booklet
+)
+
+set(TRANSLATIONS_DIR
+ "${DATA_DIR}/translations"
+)
+add_definitions(-DTRANSLATIONS_DIR=\"${TRANSLATIONS_DIR}\")
+
+
+############################################
+if (NOT CMAKE_BUILD_TYPE)
+ set ( CMAKE_BUILD_TYPE Release )
+endif (NOT CMAKE_BUILD_TYPE)
+set(CMAKE_BUILD_TYPE Debug)
+#if(CMAKE_COMPILER_IS_GNUCXX)
+# add_definitions (-Wall -pedantic)
+#endif()
+
+#*******************************************
+
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/third-party
+ ${CMAKE_CURRENT_SOURCE_DIR}/third-party/libspectre
+ ${CMAKE_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
+find_package(Qt4 REQUIRED)
+find_package(Ghostscript REQUIRED)
+
+include(${QT_USE_FILE})
+qt4_wrap_cpp(MOC_SOURCES ${MOCS})
+qt4_add_resources(QRC_SOURCES ${RESOURCES})
+qt4_wrap_ui(UI_HEADERS ${UI_FILES})
+qt4_add_translation(QM_FILES ${TS_FILES})
+
+
+add_executable(booklet ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QM_FILES} ${QRC_SOURCES} ${UI_HEADERS})
+target_link_libraries(booklet ${LIBRARIES} ${QT_LIBRARIES} ${GHOSTSCRIPT_LIBRARIES})
+
+install(FILES ${QM_FILES} DESTINATION ${TRANSLATIONS_DIR})
+install(TARGETS booklet RUNTIME DESTINATION ${GUI_DIR})
+
+
+
+
@@ -0,0 +1,103 @@
+# +-----------------------------------------------------------------------------+
+# | Copyright (C) 2012 |
+# | Lars B"ahren (lbaehren@gmail.com) |
+# | |
+# | This program is free software; you can redistribute it and/or modify |
+# | it under the terms of the GNU General Public License as published by |
+# | the Free Software Foundation; either version 2 of the License, or |
+# | (at your option) any later version. |
+# | |
+# | This program is distributed in the hope that it will be useful, |
+# | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+# | GNU General Public License for more details. |
+# | |
+# | You should have received a copy of the GNU General Public License |
+# | along with this program; if not, write to the |
+# | Free Software Foundation, Inc., |
+# | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
+# +-----------------------------------------------------------------------------+
+
+# - Check for the presence of GHOSTSCRIPT
+#
+# The following variables are set when GHOSTSCRIPT is found:
+# GHOSTSCRIPT_FOUND = Set to true, if all components of GHOSTSCRIPT have been found.
+# GHOSTSCRIPT_INCLUDES = Include path for the header files of GHOSTSCRIPT
+# GHOSTSCRIPT_LIBRARIES = Link these to use GHOSTSCRIPT
+# GHOSTSCRIPT_LFLAGS = Linker flags (optional)
+
+if (NOT GHOSTSCRIPT_FOUND)
+
+ if (NOT GHOSTSCRIPT_ROOT_DIR)
+ set (GHOSTSCRIPT_ROOT_DIR ${CMAKE_INSTALL_PREFIX})
+ endif (NOT GHOSTSCRIPT_ROOT_DIR)
+
+ ##_____________________________________________________________________________
+ ## Check for the header files
+
+ find_path (GHOSTSCRIPT_INCLUDES
+ NAMES ghostscript/gdevdsp.h ghostscript/iapi.h
+ HINTS ${GHOSTSCRIPT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
+ PATH_SUFFIXES include
+ )
+
+ ##_____________________________________________________________________________
+ ## Check for the library
+
+ find_library (GHOSTSCRIPT_LIBRARIES gs
+ HINTS ${GHOSTSCRIPT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
+ PATH_SUFFIXES lib
+ )
+
+ ##_____________________________________________________________________________
+ ## Check for the executable
+
+ find_program (GS_EXECUTABLE gs
+ HINTS ${GHOSTSCRIPT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
+ PATH_SUFFIXES bin
+ )
+
+ find_program (EPS2EPS_EXECUTABLE eps2eps
+ HINTS ${GHOSTSCRIPT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
+ PATH_SUFFIXES bin
+ )
+
+ find_program (DVIPDF_EXECUTABLE dvipdf
+ HINTS ${GHOSTSCRIPT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
+ PATH_SUFFIXES bin
+ )
+
+ find_program (PS2PS2_EXECUTABLE ps2ps2
+ HINTS ${GHOSTSCRIPT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
+ PATH_SUFFIXES bin
+ )
+
+ ##_____________________________________________________________________________
+ ## Actions taken when all components have been found
+
+ find_package_handle_standard_args (GHOSTSCRIPT DEFAULT_MSG GHOSTSCRIPT_LIBRARIES GHOSTSCRIPT_INCLUDES GS_EXECUTABLE)
+
+ if (GHOSTSCRIPT_FOUND)
+ if (NOT GHOSTSCRIPT_FIND_QUIETLY)
+ message (STATUS "Found components for GHOSTSCRIPT")
+ message (STATUS "GHOSTSCRIPT_ROOT_DIR = ${GHOSTSCRIPT_ROOT_DIR}")
+ message (STATUS "GHOSTSCRIPT_INCLUDES = ${GHOSTSCRIPT_INCLUDES}")
+ message (STATUS "GHOSTSCRIPT_LIBRARIES = ${GHOSTSCRIPT_LIBRARIES}")
+ endif (NOT GHOSTSCRIPT_FIND_QUIETLY)
+ else (GHOSTSCRIPT_FOUND)
+ if (GHOSTSCRIPT_FIND_REQUIRED)
+ message (FATAL_ERROR "Could not find GHOSTSCRIPT!")
+ endif (GHOSTSCRIPT_FIND_REQUIRED)
+ endif (GHOSTSCRIPT_FOUND)
+
+ ##_____________________________________________________________________________
+ ## Mark advanced variables
+
+ mark_as_advanced (
+ GHOSTSCRIPT_ROOT_DIR
+ GHOSTSCRIPT_INCLUDES
+ GHOSTSCRIPT_LIBRARIES
+ GS_EXECUTABLE
+ )
+
+endif (NOT GHOSTSCRIPT_FOUND)
Oops, something went wrong.

0 comments on commit 0c30419

Please sign in to comment.