From 95f2a2d8b59e13dcdcd7e58ed4ec8553f039b45e Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 11 Dec 2023 04:11:27 +0900 Subject: [PATCH] Conversion to cmake building system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michele Calgaro Signed-off-by: Slávek Banko --- CMakeLists.txt | 91 +++++++++++++++++ ConfigureChecks.cmake | 72 +++++++++++++ config.h.cmake | 8 ++ doc/man/mountconfig-trinity.1 | 69 +++++++++++++ doc/man/serviceconfig-trinity.1 | 69 +++++++++++++ doc/man/userconfig-trinity.1 | 69 +++++++++++++ kde/CMakeLists.txt | 37 +++++++ mountconfig/CMakeLists.txt | 78 ++++++++++++++ mountconfig/MicroHAL.py | 2 +- mountconfig/fuser.py | 2 +- mountconfig/mountconfig.desktop | 31 +++--- mountconfig/mountconfig.py | 2 +- mountconfig/sizeview.py | 2 +- po/.gitignore | 0 serviceconfig/CMakeLists.txt | 56 +++++++++++ serviceconfig/serviceconfig.desktop | 31 +++--- serviceconfig/serviceconfig.py | 2 +- templates/kcm_module_stub.cpp.cmake | 151 ++++++++++++++++++++++++++++ userconfig/CMakeLists.txt | 61 +++++++++++ userconfig/unixauthdb.py | 2 +- userconfig/userconfig.desktop | 30 +++--- userconfig/userconfig.py | 2 +- 22 files changed, 813 insertions(+), 54 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 ConfigureChecks.cmake create mode 100644 config.h.cmake create mode 100644 doc/man/mountconfig-trinity.1 create mode 100644 doc/man/serviceconfig-trinity.1 create mode 100644 doc/man/userconfig-trinity.1 create mode 100644 kde/CMakeLists.txt create mode 100644 mountconfig/CMakeLists.txt delete mode 100644 po/.gitignore create mode 100644 serviceconfig/CMakeLists.txt create mode 100644 templates/kcm_module_stub.cpp.cmake create mode 100644 userconfig/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..fe9ca76 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,91 @@ +############################################ +# +# (C) 2023 Michele Calgaro +# Michele (DOT) Calgaro (AT) yahoo.it +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +############################################ + + +cmake_minimum_required( VERSION 3.5 ) + + +#### general package setup + +project( tde-guidance ) + + +#### include essential cmake modules + +include( FindPkgConfig ) +include( CheckSymbolExists ) +include( CheckIncludeFile ) +include( CheckLibraryExists ) +include( CheckCSourceCompiles ) +include( CheckCXXSourceCompiles ) +include( CheckTypeSize ) + + +#### include our cmake modules + +include( TDEMacros ) + + +##### set version number + +tde_set_project_version( ) + + +##### setup install paths + +include( TDESetupPaths ) +tde_setup_paths( ) + + +##### optional stuff + +option( WITH_ALL_OPTIONS "Enable all optional support" OFF ) + +option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} ) + + +##### user requested modules + +option( BUILD_ALL "Build all" ON ) +option( BUILD_DOC "Build documentation" ${BUILD_ALL} ) +option( BUILD_TRANSLATIONS "Build translations" ${BUILD_ALL} ) + + + +##### configure checks + +include( ConfigureChecks.cmake ) + + +##### global compiler settings + +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" ) +set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" ) +set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined" ) + + +##### directories + +add_subdirectory( kde ) +add_subdirectory( mountconfig ) +add_subdirectory( serviceconfig ) +add_subdirectory( userconfig ) + + +##### other data ################################ + +tde_conditional_add_project_docs( BUILD_DOC ) +#tde_conditional_add_subdirectory( BUILD_TRANSLATIONS ) + + +##### write configure files + +configure_file( config.h.cmake config.h @ONLY ) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake new file mode 100644 index 0000000..0bd03ff --- /dev/null +++ b/ConfigureChecks.cmake @@ -0,0 +1,72 @@ +########################################### +# # +# Improvements and feedback are welcome # +# # +# This file is released under GPL >= 3 # +# # +########################################### + + +# required stuff +find_package( TQt ) +find_package( TDE ) + +tde_setup_architecture_flags( ) + +include(TestBigEndian) +test_big_endian(WORDS_BIGENDIAN) + +tde_setup_largefiles( ) + + +##### check for gcc visibility support + +if( WITH_GCC_VISIBILITY ) + tde_setup_gcc_visibility( ) +endif( WITH_GCC_VISIBILITY ) + + +##### find python libraries + +if( ${CMAKE_VERSION} VERSION_LESS "3.12" ) + find_package( PythonInterp ) + find_package( PythonLibs ) + if( NOT PYTHONLIBS_FOUND ) + tde_message_fatal( "Python is required, but was not found on your system" ) + endif( NOT PYTHONLIBS_FOUND ) +else( ) + find_package( Python COMPONENTS Interpreter Development ) + if( NOT Python_Development_FOUND ) + tde_message_fatal( "Python is required, but was not found on your system" ) + endif( ) + set( PYTHON_EXECUTABLE ${Python_EXECUTABLE} ) + set( PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS} ) + set( PYTHON_LIBRARIES ${Python_LIBRARIES} ) +endif( ) + + +##### find python setuptools location and set tde-guidance package location + +execute_process( + COMMAND "${PYTHON_EXECUTABLE}" -c "import os; import setuptools; print(os.path.dirname(setuptools.__path__[0]))" + OUTPUT_VARIABLE TDE_GUIDANCE_DIST_PKG_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE +) +set( TDE_GUIDANCE_DIST_PKG_PATH ${TDE_GUIDANCE_DIST_PKG_PATH}/tde-guidance ) + + +##### find pytquic executable + +find_program( PYTQUIC_EXECUTABLE NAMES pytquic ) + +if( NOT PYTQUIC_EXECUTABLE ) + tde_message_fatal( "pytquic is required, but was not found on your system" ) +endif() + + +##### find pythonize library + +find_library( PYTHONIZE_LIBRARIES pythonize HINTS ${LIB_INSTALL_DIR} ) +if( "${PYTHONIZE_LIBRARIES}" STREQUAL "PYTHONIZE_LIBRARIES-NOTFOUND" ) + tde_message_fatal( "pythonize library is required, but was not found on your system" ) +endif( ) diff --git a/config.h.cmake b/config.h.cmake new file mode 100644 index 0000000..61ede3a --- /dev/null +++ b/config.h.cmake @@ -0,0 +1,8 @@ +#define VERSION "@VERSION@" + +// Defined if you have fvisibility and fvisibility-inlines-hidden support. +#cmakedefine __KDE_HAVE_GCC_VISIBILITY 1 + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@ diff --git a/doc/man/mountconfig-trinity.1 b/doc/man/mountconfig-trinity.1 new file mode 100644 index 0000000..d3076cc --- /dev/null +++ b/doc/man/mountconfig-trinity.1 @@ -0,0 +1,69 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.TH "MOUNTCONFIG" "1" "aout 2, 2005" "" "" +.SH "NAME" +mountconfig \- disk and filesystem administration tool +.SH "SYNOPSIS" +.B mountconfig +.RI [ options ] +.br +.SH "DESCRIPTION" +This manual page documents briefly the +.B mountconfig +commands. This manual page was written for the Debian distribution +because the original program does not have a manual page. +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\fP escape sequences to invode bold face and italics, +.\" respectively. +\fBmountconfig\fP is a disk and filesystem administration tool. +.SH "OPTIONS" +These programs follow the usual GNU command line syntax, with long +options starting with two dashes (`\-'). +A summary of options is included below. +.TP +.B \-\-help +Show summary of options. +.TP +.B \-\-help\-qt +Show QT specific help (common for all QT apps). +.TP +.B \-\-help\-tde +Show TDE specific help (common for all TDE apps). +.TP +.B \-\-help\-all +Show the complete help. +.TP +.B \-\-author +Show program author(s). +.TP +.B \-v, \-\-version +Show version of program. +.TP +.B \-\-license +Show program license. +.SH "SEE ALSO" +.BR displayconfig (1), +.BR displayconfig-restore (1), +.BR serviceconfig (1), +.BR userconfig (1). +.br +.SH "AUTHOR" +mountconfig was written by . +.PP +This manual page was written by Fathi Boudra , +for the Debian project (but may be used by others). diff --git a/doc/man/serviceconfig-trinity.1 b/doc/man/serviceconfig-trinity.1 new file mode 100644 index 0000000..8ef180d --- /dev/null +++ b/doc/man/serviceconfig-trinity.1 @@ -0,0 +1,69 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.TH "SERVICECONFIG" "1" "aout 2, 2005" "" "" +.SH "NAME" +serviceconfig \- Service/daemon administration tool +.SH "SYNOPSIS" +.B serviceconfig +.RI [ options ] +.br +.SH "DESCRIPTION" +This manual page documents briefly the +.B serviceconfig +commands. This manual page was written for the Debian distribution +because the original program does not have a manual page. +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\fP escape sequences to invode bold face and italics, +.\" respectively. +\fBserviceconfig\fP is a service/daemon administration tool. +.SH "OPTIONS" +These programs follow the usual GNU command line syntax, with long +options starting with two dashes (`\-'). +A summary of options is included below. +.TP +.B \-\-help +Show summary of options. +.TP +.B \-\-help\-qt +Show QT specific help (common for all QT apps). +.TP +.B \-\-help\-tde +Show TDE specific help (common for all TDE apps). +.TP +.B \-\-help\-all +Show the complete help. +.TP +.B \-\-author +Show program author(s). +.TP +.B \-v, \-\-version +Show version of program. +.TP +.B \-\-license +Show program license. +.SH "SEE ALSO" +.BR displayconfig (1), +.BR displayconfig-restore (1), +.BR mountconfig (1), +.BR userconfig (1). +.br +.SH "AUTHOR" +serviceconfig was written by . +.PP +This manual page was written by Fathi Boudra , +for the Debian project (but may be used by others). diff --git a/doc/man/userconfig-trinity.1 b/doc/man/userconfig-trinity.1 new file mode 100644 index 0000000..1fda3dd --- /dev/null +++ b/doc/man/userconfig-trinity.1 @@ -0,0 +1,69 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.TH "USERCONFIG" "1" "aout 2, 2005" "" "" +.SH "NAME" +userconfig \- user and group administration tool +.SH "SYNOPSIS" +.B userconfig +.RI [ options ] +.br +.SH "DESCRIPTION" +This manual page documents briefly the +.B userconfig +commands. This manual page was written for the Debian distribution +because the original program does not have a manual page. +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\fP escape sequences to invode bold face and italics, +.\" respectively. +\fBuserconfig\fP is an user and group administration tool. +.SH "OPTIONS" +These programs follow the usual GNU command line syntax, with long +options starting with two dashes (`\-'). +A summary of options is included below. +.TP +.B \-\-help +Show summary of options. +.TP +.B \-\-help\-qt +Show QT specific help (common for all QT apps). +.TP +.B \-\-help\-tde +Show TDE specific help (common for all TDE apps). +.TP +.B \-\-help\-all +Show the complete help. +.TP +.B \-\-author +Show program author(s). +.TP +.B \-v, \-\-version +Show version of program. +.TP +.B \-\-license +Show program license. +.SH "SEE ALSO" +.BR displayconfig (1), +.BR displayconfig-restore (1), +.BR mountconfig (1), +.BR serviceconfig (1). +.br +.SH "AUTHOR" +userconfig was written by . +.PP +This manual page was written by Fathi Boudra , +for the Debian project (but may be used by others). diff --git a/kde/CMakeLists.txt b/kde/CMakeLists.txt new file mode 100644 index 0000000..6f2fa92 --- /dev/null +++ b/kde/CMakeLists.txt @@ -0,0 +1,37 @@ + +##### png files + +file( GLOB _png_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*/pics/*.png ) + +install( + FILES ${_png_files} + DESTINATION ${DATA_INSTALL_DIR}/guidance/pics +) + + +##### icon files + +file( GLOB _icons16_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*/pics/16x16/*.png ) + +install( + FILES ${_icons16_files} + DESTINATION ${ICON_INSTALL_DIR}/crystalsvg/16x16/apps +) + +install( + FILES serviceconfig/pics/hi32-app-daemons.png + DESTINATION ${ICON_INSTALL_DIR}/crystalsvg/32x32/apps + RENAME daemons.png +) + +install( + FILES mountconfig/pics/kcmpartitions.png + DESTINATION ${ICON_INSTALL_DIR}/crystalsvg/32x32/apps + RENAME disksfilesystems.png +) + +install( + FILES userconfig/pics/hi32-user.png + DESTINATION ${ICON_INSTALL_DIR}/crystalsvg/32x32/apps + RENAME userconfig.png +) diff --git a/mountconfig/CMakeLists.txt b/mountconfig/CMakeLists.txt new file mode 100644 index 0000000..0368f57 --- /dev/null +++ b/mountconfig/CMakeLists.txt @@ -0,0 +1,78 @@ + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${PYTHON_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${TDE_INCLUDE_DIR} +) + +link_directories( + ${TQT_LIBRARY_DIRS} + ${TDE_LIBRARY_DIRS} +) + + +##### generate kcm control module code + +set( MODULE_NAME mountconfig ) + +set( _MODULEDIR_ ${DATA_INSTALL_DIR}/guidance ) +set( _EXTRAMODULE_ ${TDE_GUIDANCE_DIST_PKG_PATH} ) +set( _MODULENAME_ ${MODULE_NAME} ) +set( _FACTORYFUNCTION_ create_${MODULE_NAME} ) + +configure_file( + ${CMAKE_SOURCE_DIR}/templates/kcm_module_stub.cpp.cmake + ${CMAKE_CURRENT_BINARY_DIR}/kcm_${MODULE_NAME}.cpp @ONLY +) + + +##### kcm_userconfig (module) ####################### + +tde_add_kpart( kcm_${MODULE_NAME} AUTOMOC + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/kcm_${MODULE_NAME}.cpp + + LINK + tdecore-shared tdeui-shared + ${PYTHON_LIBRARIES} ${PYTHONIZE_LIBRARIES} + ${CMAKE_DL_LIBS} + + DESTINATION ${PLUGIN_INSTALL_DIR} +) + + +##### Generate UI files + +add_custom_command( + OUTPUT fuser_ui.py + COMMAND ${PYTQUIC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/fuser_ui.ui + -o ${CMAKE_CURRENT_BINARY_DIR}/fuser_ui.py + COMMENT "Gerenate fuser_ui.py" +) + +add_custom_target( fuser_ui-pytquic ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fuser_ui.py +) + + +##### other files + +tde_create_translated_desktop( + SOURCE ${MODULE_NAME}.desktop + DESTINATION ${XDG_APPS_INSTALL_DIR} +) + +install( + FILES + SimpleCommandRunner.py SMBShareSelectDialog.py MicroHAL.py + fuser.py ${CMAKE_CURRENT_BINARY_DIR}/fuser_ui.py sizeview.py + DESTINATION ${TDE_GUIDANCE_DIST_PKG_PATH} +) + +install( + PROGRAMS ${MODULE_NAME}.py + DESTINATION ${TDE_GUIDANCE_DIST_PKG_PATH} +) + +tde_install_symlink( ${TDE_GUIDANCE_DIST_PKG_PATH}/${MODULE_NAME}.py ${BIN_INSTALL_DIR}/${MODULE_NAME} ) diff --git a/mountconfig/MicroHAL.py b/mountconfig/MicroHAL.py index a7b02ae..f264c41 100755 --- a/mountconfig/MicroHAL.py +++ b/mountconfig/MicroHAL.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ########################################################################### # MicroHAL.py - # # ------------------------------ # diff --git a/mountconfig/fuser.py b/mountconfig/fuser.py index 87d0719..e91bd7b 100644 --- a/mountconfig/fuser.py +++ b/mountconfig/fuser.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ########################################################################### # fuser.py - description # # ------------------------------ # diff --git a/mountconfig/mountconfig.desktop b/mountconfig/mountconfig.desktop index da36d84..fb3aab8 100644 --- a/mountconfig/mountconfig.desktop +++ b/mountconfig/mountconfig.desktop @@ -12,8 +12,20 @@ Name[pt_BR]=Disco & Sistemas de Arquivos Name[sr]=Диск и фајл-системи Name[sr@Latn]=Disk i fajl-sistemi Name[sv]=Disk- och filsystem -Name[xx]=xxDisk & Filesystemsxx -name[en_GB]=Disk & Filesystems + +GenericName=Mount Point Editor +GenericName[el]=Επεξεργαστής σημείων προσάρτησης +GenericName[es]=Editor del punto de montaje +GenericName[et]=Ühenduspunktide redaktor +GenericName[it]=Editor dei punti di montaggio +GenericName[ja]=マウントポイントエディタ +GenericName[nl]=Aankoppelpunten bewerken +GenericName[pt]=Editor de Pontos de Montagem +GenericName[pt_BR]=Editor de Pontos de Montagem +GenericName[sr]=Уређивач тачки монтирања +GenericName[sr@Latn]=Uređivač tački montiranja +GenericName[sv]=Editor för monteringspunkter + Comment=Disk & Filesystem Configuration Comment[el]=Ρυθμίσεις δίσκων & συστημάτων αρχείων Comment[es]=Configuración del disco y sistema de archivos @@ -26,7 +38,7 @@ Comment[pt_BR]=Configuração de Disco e Sistemas de Arquivos Comment[sr]=Подешавање диска и фајл-система Comment[sr@Latn]=Podešavanje diska i fajl-sistema Comment[sv]=Disk och filsysteminitierníng -Comment[xx]=xxDisk & Filesystem Configurationxx + Icon=disksfilesystems Encoding=UTF-8 X-TDE-ModuleType=Library @@ -36,16 +48,3 @@ X-TDE-RootOnly=true Type=Application Exec=tdecmshell System/mountconfig Categories=Qt;TDE;X-TDE-settings-system; -GenericName=Mount Point Editor -GenericName[el]=Επεξεργαστής σημείων προσάρτησης -GenericName[es]=Editor del punto de montaje -GenericName[et]=Ühenduspunktide redaktor -GenericName[it]=Editor dei punti di montaggio -GenericName[ja]=マウントポイントエディタ -GenericName[nl]=Aankoppelpunten bewerken -GenericName[pt]=Editor de Pontos de Montagem -GenericName[pt_BR]=Editor de Pontos de Montagem -GenericName[sr]=Уређивач тачки монтирања -GenericName[sr@Latn]=Uređivač tački montiranja -GenericName[sv]=Editor för monteringspunkter -GenericName[xx]=xxMount Point Editorxx diff --git a/mountconfig/mountconfig.py b/mountconfig/mountconfig.py index eb28cae..4e65ef2 100755 --- a/mountconfig/mountconfig.py +++ b/mountconfig/mountconfig.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: UTF-8 -*- ########################################################################### # mountconfig.py - description # diff --git a/mountconfig/sizeview.py b/mountconfig/sizeview.py index fc94c46..b6c57ad 100644 --- a/mountconfig/sizeview.py +++ b/mountconfig/sizeview.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 from PyTQt.tqt import * from tdecore import * diff --git a/po/.gitignore b/po/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/serviceconfig/CMakeLists.txt b/serviceconfig/CMakeLists.txt new file mode 100644 index 0000000..5a2a3ca --- /dev/null +++ b/serviceconfig/CMakeLists.txt @@ -0,0 +1,56 @@ +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${PYTHON_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${TDE_INCLUDE_DIR} +) + +link_directories( + ${TQT_LIBRARY_DIRS} + ${TDE_LIBRARY_DIRS} +) + + +##### generate kcm control module code + +set( MODULE_NAME serviceconfig ) + +set( _MODULEDIR_ ${DATA_INSTALL_DIR}/guidance ) +set( _EXTRAMODULE_ ${TDE_GUIDANCE_DIST_PKG_PATH} ) +set( _MODULENAME_ ${MODULE_NAME} ) +set( _FACTORYFUNCTION_ create_${MODULE_NAME} ) + +configure_file( + ${CMAKE_SOURCE_DIR}/templates/kcm_module_stub.cpp.cmake + ${CMAKE_CURRENT_BINARY_DIR}/kcm_${MODULE_NAME}.cpp @ONLY +) + + +##### kcm_userconfig (module) ####################### + +tde_add_kpart( kcm_${MODULE_NAME} AUTOMOC + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/kcm_${MODULE_NAME}.cpp + + LINK + tdecore-shared tdeui-shared + ${PYTHON_LIBRARIES} ${PYTHONIZE_LIBRARIES} + ${CMAKE_DL_LIBS} + + DESTINATION ${PLUGIN_INSTALL_DIR} +) + + +##### other files + +tde_create_translated_desktop( + SOURCE ${MODULE_NAME}.desktop + DESTINATION ${XDG_APPS_INSTALL_DIR} +) + +install( + PROGRAMS ${MODULE_NAME}.py + DESTINATION ${TDE_GUIDANCE_DIST_PKG_PATH} +) + +tde_install_symlink( ${TDE_GUIDANCE_DIST_PKG_PATH}/${MODULE_NAME}.py ${BIN_INSTALL_DIR}/${MODULE_NAME} ) diff --git a/serviceconfig/serviceconfig.desktop b/serviceconfig/serviceconfig.desktop index f85c812..0ccfdf4 100644 --- a/serviceconfig/serviceconfig.desktop +++ b/serviceconfig/serviceconfig.desktop @@ -11,8 +11,20 @@ Name[pt_BR]=Serviços do Sistema Name[sr]=Системски сервиси Name[sr@Latn]=Sistemski servisi Name[sv]=Systemtjänster -Name[xx]=xxSystem Servicesxx -name[en_GB]=System Services + +GenericName=Runlevel Editor +GenericName[el]=Επεξεργαστής επιπέδων εκτέλεσης +GenericName[es]=Editor del nivel de ejecución +GenericName[et]=Käitustasemete redaktor +GenericName[it]=Editor dei runlevel +GenericName[ja]=ランレベルエディタ +GenericName[nl]=Runlevel-bewerker +GenericName[pt]=Editor de Níveis de Execução +GenericName[pt_BR]=Editor de Níveis de Execução +GenericName[sr]=Уређивач радних нивоа +GenericName[sr@Latn]=Uređivač radnih nivoa +GenericName[sv]=Editor för körnivå + Comment=System Service Configuration Comment[el]=Ρυθμίσεις υπηρεσιών συστήματος Comment[es]=Configuración del servicio del sistema @@ -25,7 +37,7 @@ Comment[pt_BR]=Configuração dos Serviços do Sistema Comment[sr]=Подешавање системских сервиса Comment[sr@Latn]=Podešavanje sistemskih servisa Comment[sv]=Inställning av systemtjänster -Comment[xx]=xxSystem Service Configurationxx + Icon=daemons Encoding=UTF-8 X-TDE-ModuleType=Library @@ -35,16 +47,3 @@ X-TDE-RootOnly=true Type=Application Exec=tdecmshell System/serviceconfig Categories=Qt;TDE;X-TDE-settings-system; -GenericName=Runlevel Editor -GenericName[el]=Επεξεργαστής επιπέδων εκτέλεσης -GenericName[es]=Editor del nivel de ejecución -GenericName[et]=Käitustasemete redaktor -GenericName[it]=Editor dei runlevel -GenericName[ja]=ランレベルエディタ -GenericName[nl]=Runlevel-bewerker -GenericName[pt]=Editor de Níveis de Execução -GenericName[pt_BR]=Editor de Níveis de Execução -GenericName[sr]=Уређивач радних нивоа -GenericName[sr@Latn]=Uređivač radnih nivoa -GenericName[sv]=Editor för körnivå -GenericName[xx]=xxRunlevel Editorxx diff --git a/serviceconfig/serviceconfig.py b/serviceconfig/serviceconfig.py index 42bb543..220a370 100755 --- a/serviceconfig/serviceconfig.py +++ b/serviceconfig/serviceconfig.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: UTF-8 -*- ########################################################################### # serviceconfig.py - description # diff --git a/templates/kcm_module_stub.cpp.cmake b/templates/kcm_module_stub.cpp.cmake new file mode 100644 index 0000000..91536c7 --- /dev/null +++ b/templates/kcm_module_stub.cpp.cmake @@ -0,0 +1,151 @@ +/* + * pykcm_launcher.cpp + * + * Launch Control Centre modules written in Python using an embedded Python + * interpreter. + * Based on David Boddie's PyTDE-components. + */ + +// pythonize.h must be included first. +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif // _GNU_SOURCE +#include + +#define MODULE_DIR "@_MODULEDIR_@" +#define EXTRA_MODULE_DIR "@_EXTRAMODULE_@" +#define MODULE_NAME "@_MODULENAME_@" +#define FACTORY "@_FACTORYFUNCTION_@" +#define CPP_FACTORY @_FACTORYFUNCTION_@ +#define debug 1 + +static TDECModule *report_error(const char *msg) { + if (debug) printf ("error: %s\n", msg); + return NULL; +} + +static TDECModule* return_instance( TQWidget *parent, const char *name ) { + TDECModule* tdecmodule; + PyObject *pyTDECModuleTuple; + PyObject *pyTDECModule; + Pythonize *pyize; // Pythonize object to manage the Python interpreter. + + // Try to determine what py script we're loading. Note that "name" + // typically appears to be NULL. + TQString script(MODULE_NAME); + + // Reload this module, but this time tell the runtime linker to make the + // symbols global and available for later loaded libraries/module. + Dl_info info; + if (!dladdr((const void *)(&return_instance), &info) || !info.dli_fname || !dlopen(info.dli_fname, RTLD_GLOBAL|RTLD_NOW)) { + return report_error ("***Unable to export symbols\n"); + } + + // Start the interpreter. + pyize = initialize(); + if (!pyize) { + return report_error ("***Failed to start interpreter\n"); + } + + // Add the path to the python script to the interpreter search path. + TQString path = TQString(MODULE_DIR); + if(path == TQString::null) { + return report_error ("***Failed to locate script path"); + } + if(!pyize->appendToSysPath (path.latin1 ())) { + return report_error ("***Failed to set sys.path\n"); + } + + // Add the extra path to the python script to the interpreter search path. + TQString extrapath = TQString(EXTRA_MODULE_DIR); + if(!pyize->appendToSysPath (extrapath.latin1 ())) { + return report_error ("***Failed to set extra sys.path\n"); + } + + // Load the Python script. + PyObject *pyModule = pyize->importModule ((char *)script.latin1 ()); + if(!pyModule) { + PyErr_Print(); + return report_error ("***failed to import module\n"); + } + + // Inject a helper function + TQString bridge = TQString("import sip_tqt\n" + "from PyTQt import tqt\n" + "def kcontrol_bridge_" FACTORY "(parent,name):\n" + " if parent!=0:\n" + " wparent = sip_tqt.wrapinstance(parent,tqt.TQWidget)\n" + " else:\n" + " wparent = None\n" + " inst = " FACTORY "(wparent, name)\n" + " return (inst,sip_tqt.unwrapinstance(inst))\n"); + PyRun_String(bridge.latin1(),Py_file_input,PyModule_GetDict(pyModule),PyModule_GetDict(pyModule)); + + // Get the Python module's factory function. + PyObject *kcmFactory = pyize->getNewObjectRef(pyModule, "kcontrol_bridge_" FACTORY); + if(!kcmFactory) { + return report_error ("***failed to find module factory\n"); + } + + // Call the factory function. Set up the args. + PyObject *pyParent = PyLong_FromVoidPtr(parent); + PyObject *pyName = PyBytes_FromString(MODULE_NAME); + // Using NN here is effect gives our references to the arguement away. + PyObject *args = Py_BuildValue ("NN", pyParent, pyName); + if(pyName && pyParent && args) { + // run the factory function + pyTDECModuleTuple = pyize->runFunction(kcmFactory, args); + if(!pyTDECModuleTuple) { + PyErr_Print(); + return report_error ("*** runFunction failure\n;"); + } + } else { + return report_error ("***failed to create args\n"); + } + // cleanup a bit + pyize->decref(args); + pyize->decref(kcmFactory); + + // Stop this from getting garbage collected. + Py_INCREF(PyTuple_GET_ITEM(pyTDECModuleTuple,0)); + + // convert the TDECModule PyObject to a real C++ TDECModule *. + pyTDECModule = PyTuple_GET_ITEM(pyTDECModuleTuple,1); + tdecmodule = (TDECModule *)PyLong_AsVoidPtr(pyTDECModule); + if(!tdecmodule) { + return report_error ("***failed sip-tqt conversion to C++ pointer\n"); + } + pyize->decref(pyTDECModuleTuple); + + // PyTDE can't run the module without this - Pythonize + // grabs the lock at initialization and we have to give + // it back before exiting. At this point, we no longer need + // it. + //pyize->releaseLock (); + + // take care of any translation info + TDEGlobal::locale()->insertCatalogue(script); + + // Return the pointer to our new TDECModule + return tdecmodule; +} + +extern "C" +{ + // Factory function that kcontrol will call. + KDE_EXPORT TDECModule* CPP_FACTORY(TQWidget *parent, const char *name) + { + return return_instance(parent, name); + } +} + diff --git a/userconfig/CMakeLists.txt b/userconfig/CMakeLists.txt new file mode 100644 index 0000000..c04eb7d --- /dev/null +++ b/userconfig/CMakeLists.txt @@ -0,0 +1,61 @@ +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${PYTHON_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${TDE_INCLUDE_DIR} +) + +link_directories( + ${TQT_LIBRARY_DIRS} + ${TDE_LIBRARY_DIRS} +) + + +##### generate kcm control module code + +set( MODULE_NAME userconfig ) + +set( _MODULEDIR_ ${DATA_INSTALL_DIR}/guidance ) +set( _EXTRAMODULE_ ${TDE_GUIDANCE_DIST_PKG_PATH} ) +set( _MODULENAME_ ${MODULE_NAME} ) +set( _FACTORYFUNCTION_ create_${MODULE_NAME} ) + +configure_file( + ${CMAKE_SOURCE_DIR}/templates/kcm_module_stub.cpp.cmake + ${CMAKE_CURRENT_BINARY_DIR}/kcm_${MODULE_NAME}.cpp @ONLY +) + + +##### kcm_userconfig (module) ####################### + +tde_add_kpart( kcm_${MODULE_NAME} AUTOMOC + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/kcm_${MODULE_NAME}.cpp + + LINK + tdecore-shared tdeui-shared + ${PYTHON_LIBRARIES} ${PYTHONIZE_LIBRARIES} + ${CMAKE_DL_LIBS} + + DESTINATION ${PLUGIN_INSTALL_DIR} +) + + +##### other files + +tde_create_translated_desktop( + SOURCE ${MODULE_NAME}.desktop + DESTINATION ${XDG_APPS_INSTALL_DIR} +) + +install( + FILES unixauthdb.py + DESTINATION ${TDE_GUIDANCE_DIST_PKG_PATH} +) + +install( + PROGRAMS ${MODULE_NAME}.py + DESTINATION ${TDE_GUIDANCE_DIST_PKG_PATH} +) + +tde_install_symlink( ${TDE_GUIDANCE_DIST_PKG_PATH}/${MODULE_NAME}.py ${BIN_INSTALL_DIR}/${MODULE_NAME} ) diff --git a/userconfig/unixauthdb.py b/userconfig/unixauthdb.py index e2e80c1..1523acf 100755 --- a/userconfig/unixauthdb.py +++ b/userconfig/unixauthdb.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 ########################################################################### # Copyright (C) 2004-2006 by Simon Edwards # diff --git a/userconfig/userconfig.desktop b/userconfig/userconfig.desktop index 3ab05ad..1a7e285 100644 --- a/userconfig/userconfig.desktop +++ b/userconfig/userconfig.desktop @@ -11,7 +11,20 @@ Name[pt_BR]=Gerenciamento de Usuários Name[sr]=Управљање корисницима Name[sr@Latn]=Upravljanje korisnicima Name[sv]=Användarhantering -Name[xx]=xxUser Managementxx + +GenericName=User Account Editor +GenericName[el]=Επεξεργαστής λογαριασμών χρηστών +GenericName[es]=Editor de cuenta de usuario +GenericName[et]=Kasutajakonto redaktor +GenericName[it]=Editor degli account degli utenti +GenericName[ja]=ユーザアカウントエディタ +GenericName[nl]=Gebruikeraccounts bewerken +GenericName[pt]=Editor de Contas dos Utilizadores +GenericName[pt_BR]=Editor de Contas de Usuários +GenericName[sr]=Уређивач корисничких налога +GenericName[sr@Latn]=Uređivač korisničkih naloga +GenericName[sv]=Editor för användarkonton + Comment=Users & Groups Administration Comment[el]=Διαχείριση χρηστών & ομάδων Comment[es]=Administrador de usuarios y grupos @@ -24,7 +37,7 @@ Comment[pt_BR]=Administração de Usuários & Grupos Comment[sr]=Администрирање корисника и група Comment[sr@Latn]=Administriranje korisnika i grupa Comment[sv]=Administration av användare och grupper -Comment[xx]=xxUsers & Groups Administrationxx + Icon=userconfig Encoding=UTF-8 X-TDE-ModuleType=Library @@ -34,16 +47,3 @@ X-TDE-RootOnly=true Type=Application Exec=tdecmshell System/userconfig Categories=Qt;TDE;X-TDE-settings-system; -GenericName=User Account Editor -GenericName[el]=Επεξεργαστής λογαριασμών χρηστών -GenericName[es]=Editor de cuenta de usuario -GenericName[et]=Kasutajakonto redaktor -GenericName[it]=Editor degli account degli utenti -GenericName[ja]=ユーザアカウントエディタ -GenericName[nl]=Gebruikeraccounts bewerken -GenericName[pt]=Editor de Contas dos Utilizadores -GenericName[pt_BR]=Editor de Contas de Usuários -GenericName[sr]=Уређивач корисничких налога -GenericName[sr@Latn]=Uređivač korisničkih naloga -GenericName[sv]=Editor för användarkonton -GenericName[xx]=xxUser Account Editorxx diff --git a/userconfig/userconfig.py b/userconfig/userconfig.py index 76140e8..325f0c3 100755 --- a/userconfig/userconfig.py +++ b/userconfig/userconfig.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: UTF-8 -*- ########################################################################### # userconfig.py - description #