diff --git a/Makefile b/Makefile index b66026b..649dc53 100644 --- a/Makefile +++ b/Makefile @@ -8,23 +8,25 @@ MAKEFILE_PATH := $(dir $(MAKEFILE_FILEPATH)) CMAKE_COMMAND = cmake CMAKE_SOURCE_DIR = $(MAKEFILE_PATH)source CMAKE_BUILD_DIR = $(MAKEFILE_PATH)compile -#CMAKE_SOURCE_DIR = ./source -#CMAKE_BUILD_DIR = ./compile -FILE_VERSION = VERSION.md DEPENDS = /bin/cmake -PREFIX ?= /usr +PREFIX ?= /usr/local PKGNAME = $(MAKEFILE_DIR) -#PKGNAME = ubl-settings-manager +FILE_VER = source/${PKGNAME}.h default_target: all -.PHONY: all init depend debug prepare check build uninstall install clean up_ver help +.PHONY: all init depend debug prepare check build uninstall install clean help all: init build init: @echo "Initialize ..."; \ - sed -r "s/(version_application = ).*/\1\"$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2)\";/" -i source/ubl-settings-manager.h; \ + if [ -d ".git" ]; then \ + LATEST_TAG=$$(git describe --abbrev=0 --tags | sed 's/^v//'); \ + else \ + LATEST_TAG="Development"; \ + fi; \ + sed -r "s/^(string version_application).*/\1 = \"$${LATEST_TAG}\";/" -i ${FILE_VER}; \ echo "-- Build path: ${CMAKE_BUILD_DIR}" depend: @@ -35,8 +37,8 @@ depend: exit 1; \ fi; \ done; \ + $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B${CMAKE_BUILD_DIR} --check-build-system CMakeFiles/Makefile.cmake 1 || exit 1; \ echo "Check depends: OK" -# $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 debug: @echo "Debug ..." @@ -63,7 +65,8 @@ check: build: depend prepare @echo "Build ..."; \ - make --directory=${CMAKE_BUILD_DIR}; \ + $(MAKE_COMMAND) --directory=${CMAKE_BUILD_DIR}; \ + sed -r "s/^(string version_application).*/\1;/" -i ${FILE_VER}; \ echo "Build: OK" uninstall: @@ -84,10 +87,10 @@ uninstall: done; \ done @$(RM) "${DESTDIR}${PREFIX}/bin/${PKGNAME}" - @$(RM) "${DESTDIR}${PREFIX}/etc/xdg/${PKGNAME}/${PKGNAME}.conf" + @$(RM) "${DESTDIR}/etc/xdg/${PKGNAME}/${PKGNAME}.conf" @$(RM) "${DESTDIR}${PREFIX}/share/applications/${PKGNAME}.desktop" @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.svg" - @$(RM) -rd "${DESTDIR}${PREFIX}/share/${PKGNAME}" + @$(RM) "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}.policy" @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ @@ -109,18 +112,12 @@ install: check uninstall install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps"; \ rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data "com.ublinux.${PKGNAME}.svg" -o "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \ done - @install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "com.ublinux.${PKGNAME}.policy" @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" - @install -dm755 "${DESTDIR}${PREFIX}/etc/xdg" - @install -Dm744 -t "${DESTDIR}${PREFIX}/etc/xdg/${PKGNAME}/" "${PKGNAME}.conf" - @install -dm755 "${DESTDIR}${PREFIX}/share/applications" + @install -Dm744 -t "${DESTDIR}/etc/xdg/${PKGNAME}/" "${PKGNAME}.conf" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" - @install -dm755 "${DESTDIR}${PREFIX}/share/${PKGNAME}"/{ui,css,images} - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/ui/" "${PKGNAME}.glade" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/css/" "${PKGNAME}.css" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/images/" "ublinux-logo.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/images/" "${PKGNAME}-banner.png" + @sed -e 's+/usr/bin+${PREFIX}/bin+g' -i ${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}.policy @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ @@ -137,14 +134,6 @@ clean: echo "Clean: OK"; \ fi -up_ver: - @CURRENT=$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2); \ - MAJOR=$$(cut -d. -f1 <<< $${CURRENT}); \ - MINOR=$$(cut -d. -f2 <<< $${CURRENT}); \ - VER="$${MAJOR}.$$(($${MINOR}+1))"; \ - sed "s/VERSION *[[:digit:]]*.*/VERSION $${VER}/" -i ${FILE_VERSION}; \ - echo "Updated version to VERSION.md: $${CURRENT} to $${VER}" - help: @echo "The following are some of the valid targets for this Makefile:"; \ echo "... all (the default if no target is provided)"; \ @@ -154,5 +143,4 @@ help: echo "... compile"; \ echo "... install"; \ echo "... uninstall"; \ - echo "... clean"; \ - echo "... up_ver" + echo "... clean" \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 1859049..19ec51d 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -8,22 +8,86 @@ include_directories(${GTK_INCLUDE_DIRS}) link_directories(${GTK_LIBRARY_DIRS}) add_definitions(${GTK_CFLAGS_OTHER}) +#pkg_check_modules(VTE291 REQUIRED vte-2.91) +#include_directories(${VTE291_INCLUDE_DIRS}) +#link_directories(${VTE291_LIBRARY_DIRS}) +#add_definitions(${VTE291_CFLAGS_OTHER}) + +find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) + +option(WEBKIT_FOUND "No" OFF) +if(WEBKIT_LIBRARIES_FOUND) + option(WEBKIT_FOUND "Yes" ON) + PKG_CHECK_MODULES(WEBKIT REQUIRED webkit2gtk-4.0 webkit2gtk-web-extension-4.0) + include_directories(${WEBKIT_INCLUDE_DIRS}) + link_directories(${WEBKIT_LIBRARY_DIRS}) + add_definitions(${WEBKIT_CFLAGS_OTHER}) +endif() + +configure_file(ubl-cmake.in ubl-cmake.h) + +file(COPY ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h DESTINATION ./) + +set(GRESOURCE_C resources.c) +set(GRESOURCE_XML gresource.xml) + +find_program(GLIB_COMPILE_RESOURCES NAMES glib-compile-resources REQUIRED) +add_custom_target(GLADE ubl-settings-manager.glade) + +set(DEPENDFILES + ../ubl-settings-manager.glade + ../gresource.xml + ../ubl-settings-manager-banner.png + ../ubl-settings-manager.css + ) + +file(COPY ${DEPENDFILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + +add_custom_command( + OUTPUT ${GRESOURCE_C} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${GLIB_COMPILE_RESOURCES} + ARGS + --generate-source + --target=${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C} + ${GRESOURCE_XML} + VERBATIM + MAIN_DEPENDENCY ${GRESOURCE_XML} + DEPENDS + ${GLADE} +) +add_custom_target( + dummy-resource + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C} +) + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a") #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -lm") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ -O2 -pipe -fno-plt -fexceptions \ -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ -fstack-clash-protection -fcf-protection") + set(SOURCE_FILES ubl-settings-manager.c - ubl-settings-manager.h) + ubl-settings-manager.h + ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h + ) set(LIBRARIES ${GTK_LIBRARIES} + ${WEBKIT_LIBRARIES} +# ${VTE291_LIBRARIES} pthread) -add_executable(ubl-settings-manager ${SOURCE_FILES}) -target_link_libraries(ubl-settings-manager ${LIBRARIES}) -install(TARGETS ubl-settings-manager DESTINATION bin) \ No newline at end of file +add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${LIBRARIES}) +target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_BINARY_DIR}) +set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C} + PROPERTIES GENERATED TRUE +) +install(TARGETS ${PROJECT_NAME} DESTINATION bin) +add_dependencies(${PROJECT_NAME} dummy-resource) \ No newline at end of file diff --git a/source/ubl-settings-manager.h b/source/ubl-settings-manager.h index af8076c..04d1de1 100644 --- a/source/ubl-settings-manager.h +++ b/source/ubl-settings-manager.h @@ -4,24 +4,56 @@ #include #include #include +#include +#include "ubl-cmake.h" +#ifdef WEBKIT_FOUND +#include +#endif + +#define UBLINUX_WIKI_COMMAND "xdg-open https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-manager" +#define UBLINUX_WIKI_LINK " https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-manager" + +#define check_web2kit_command "ldconfig -p |grep webkit2" #define cmdVersionText yon_char_get_augumented(yon_char_get_augumented(_("Version: "),version_application),"\n") #define cmdHelpText yon_char_get_augumented(yon_char_get_augumented(_("ubl-settings-manager version: "),version_application),_("\nGTK settings manager for UBLinux\nUsage: ubl-settings-manager [OPTIONS...]\nOptions:\n -h, --help Show this help\n -V, --version Show package version\n --lock-settings Lock menu settings\n")) -#define GladePath "/usr/share/ubl-settings-manager/ui/ubl-settings-manager.glade" -#define CssPath "/usr/share/ubl-settings-manager/css/ubl-settings-manager.css" +#define GladePath "/com/ublinux/ui/ubl-settings-manager.glade" +#define CssPath "/com/ublinux/css/ubl-settings-manager.css" #define GlobalConfigPath "/etc/xdg/ubl-settings-manager/ubl-settings-manager.conf" #define UserConfigPath "/.config/ubl-settings-manager/ubl-settings-manager.conf" #define AppIconPath "com.ublinux.ubl-settings-manager" -#define AppBannerPath "/usr/share/ubl-settings-manager/images/ubl-settings-manager-banner.png" +#define AppBannerPath "/com/ublinux/images/ubl-settings-manager-banner.png" #define DesktopPath "/usr/share/applications/" #define IconPicturesPath "/usr/share/icons/hicolor/scalable/apps/" -#define ublinux_logo "/usr/share/ubl-settings-manager/images/ublinux-logo.svg" #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-manager" #define ubl_settings_infoPath "ubl-settings-info" #define ubl_settings_infoPathLaunch "ubl-settings-info --socket-id=" typedef char* string; -string version_application = "1.2"; +string version_application; + +#define UBL_SETTINGS_MANAGER_TITLE _("UBLinux Settings Manager") +#define UBL_SETTINGS_MANAGER_ABOUT_TITLE _("About UBLinux Settings Manager") +#define ABOUT_PROJECT_HOME_PAGE_LABEL _("Project Home Page") +#define ABOUT_PROJECT_COMMENTS_LABEL _("Settings manager for UBLinux") +#define CONFIG_LOAD_ERROR _("Config loading failed!\n") +#define DOUBLE_CLICK_SELECTION_LABEL _("Double click selection") +#define SECTIONS_MANAGEMENT_LABEL _("Sections management") +#define UNDERSTOOD_LABEL _("Understood") +#define ABOUT_LABEL _("About...") +#define DOCUMENTATION_LABEL _("Documentation") +#define SETTINGS_LABEL _("Settings") +#define ALWAYS_REDIRECT_LABEL _("Always redirect") +#define APPLY_LABEL _("Apply") +#define SAVE_AND_APPLY_LABEL _("Save and apply") +#define CLOSE_LABEL _("Close") +#define CANCEL_LABEL _("Cancel") +#define READ_ONLINE_LABEL _("Read online") +#define REDIRECTION_COMMENT_LABEL _("You will be redirected to documentation site, where user help pages are translated and supported by community.") +#define REDIRECTION_LABEL _("Would you like to read documentation in the Web?") +#define WINDOW_THEME_LABEL _("Window theme") +#define ICON_SIZE_LABEL _("Icon size") +#define BACK_TO_ALL_SETTINGS_LABEL _("All settings") typedef struct apps{ @@ -83,7 +115,11 @@ typedef struct { int changed; int fullscreen; int lock_settings; + int GnomeDoubleClick; + int MainDoubleClick; + int *currentDoubleClick; dictionary *SettingsSections; + int BannerHidden; } config; typedef struct { @@ -165,6 +201,11 @@ typedef struct { GtkWidget *infoWarningWindow; GtkWidget *infoWarningButton; GtkWidget *infoWarningLabel; + GtkWidget *BannerRevealer; + GtkWidget *Revealer; + GtkWidget *settingsDoubleClickSwitch; + GtkWidget *settingsDoubleClickLabel; + GtkWidget *BackToSettingsLabel; } actionWidgets; @@ -203,6 +244,7 @@ void sort_apps(apps *applist,int size); apps *find_apps(int *sizef); int check_categories(apps app, char *catstocheck); int setup_config(); +void update_double_clicks(dictionary *widgetsD); void yon_icv_resize_item(dictionary *icdict, GtkWidget *paned); dictionary *yon_theme_new(dictionary **widgetss, GtkBuilder *builder, char *theme_id, apps *applist, int appsize); char *yon_char_get_augumented(char *source, char *append); @@ -221,6 +263,7 @@ dictionary *yon_dictionary_get_last(dictionary *dict); dictionary *yon_dictionary_switch_places(dictionary *dict,int aim); dictionary *yon_dictionary_create_with_data(char *key, void *data); dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data); +dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect); SectionSettingSegment *yon_create_section_setting(char *name, char *categories); void yon_segments_show(actionWidgets *widgets); void yon_segments_hide(actionWidgets *widgets); @@ -235,5 +278,6 @@ void yon_time_reg_for_average(dictionary *listofregs, int size, time_t tm); void yon_dictionary_switch_to_last(dictionary **dict); dictionary *yon_dictionary_create_conneced(dictionary *targetdict); int yon_get_icon_size(int size); +char *yon_char_from_int(int int_to_convert); #endif \ No newline at end of file