From d2579e5315b2eb529a3f959825657a49a112a1b1 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 19 Jul 2023 10:03:52 +0600 Subject: [PATCH] reverting --- Makefile | 156 +++++++++++++++++----------------- source/CMakeLists.txt | 6 +- source/ubl-settings-manager.h | 35 +++++--- 3 files changed, 108 insertions(+), 89 deletions(-) diff --git a/Makefile b/Makefile index 32ef201..b66026b 100644 --- a/Makefile +++ b/Makefile @@ -6,48 +6,49 @@ MAKEFILE_DIR := $(notdir $(patsubst %/,%,$(dir $(MAKEFILE_FILEPATH)))) 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 -DEPENDS = 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 PKGNAME = $(MAKEFILE_DIR) #PKGNAME = ubl-settings-manager -pkgdir = default_target: all +.PHONY: all init depend debug prepare check build uninstall install clean up_ver help + all: init build init: @echo "Initialize ..."; \ - version="$$(cat VERSION.md)"; \ - version=$${version:8}; \ - search="s/char *version_application.*$&"; \ - replace="char *version_application = \"$${version}\";"; \ - sed -i -e "$$search/$$replace/gi" source/ubl-settings-manager.h; \ - echo "-- Build path: ${CMAKE_BUILD_DIR}" - + sed -r "s/(version_application = ).*/\1\"$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2)\";/" -i source/ubl-settings-manager.h; \ + echo "-- Build path: ${CMAKE_BUILD_DIR}" + depend: - @echo "Check depends ..."; \ - if [ ! -f /bin/cmake ]; then \ - echo "-- Depend 'cmake' not found !"; \ - exit 1; \ - fi; \ + @echo "Check depends ..." + @for FILE_DEPEND in $(DEPENDS); do \ + if [ ! -f $${FILE_DEPEND} ]; then \ + echo "ERROR: Depend '$${FILE_DEPEND}' not found !"; \ + exit 1; \ + fi; \ + done; \ echo "Check depends: OK" # $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 debug: @echo "Debug ..." if [ ! -d ${CMAKE_BUILD_DIR} ]; then \ - cmake -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="/usr"; \ + $(CMAKE_COMMAND) -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \ fi; \ echo "Debug: OK" prepare: @echo "Prepare ..."; \ if [ ! -d ${CMAKE_BUILD_DIR} ]; then \ - cmake -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/usr"; \ + $(CMAKE_COMMAND) -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \ fi; \ echo "Prepare: OK" @@ -67,70 +68,64 @@ build: depend prepare uninstall: @echo "Uninstall ..." + @for FILE_PO in $(wildcard *.po); do \ + LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \ + FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \ + PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ + $(RM) "$${PATH_FILE_MO}"; \ + done @for SIZE in 16x16 32x32 48x48 scalable; do \ - $(RM) "/usr/share/icons/hicolor/$${SIZE}/apps/${PKGNAME}.svg"; \ - $(RM) "/usr/share/"${pkgname}"/images/${PKGNAME}.png"; \ + $(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \ + $(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/apps/com.ublinux.${PKGNAME}.png"; \ done @for FILE_SVG in $(wildcard *.svg); do \ for SIZE in 16x16 32x32 48x48 scalable; do \ - $(RM) "/usr/share/icons/hicolor/$${SIZE}/status/$${FILE_SVG%.*}".{svg,png,jpg}; \ + $(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/status/$${FILE_SVG%.*}".{svg,png,jpg}; \ done; \ done - @for FILE_PO in $(wildcard *.po); do \ - LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \ - FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \ - PATH_FILE_MO="/usr/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ - $(RM) "/usr/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ - done - @$(RM) "/usr/bin/${PKGNAME}" - @$(RM) "/usr/share/applications/${PKGNAME}.desktop" - @$(RM) "/usr/share/icons/hicolor/scalable/apps/${PKGNAME}.png" - @$(RM) "/usr/share/icons/hicolor/scalable/apps/${PKGNAME}.svg" - @$(RM) "/usr/share/icons/hicolor/scalable/apps/ubl-settings-manager.svg" - @$(RM) "/usr/share/${PKGNAME}/ui/ublinux-logo.svg" - @$(RM) "/usr/share/${PKGNAME}/ui/${PKGNAME}.glade" - @$(RM) "/usr/share/${PKGNAME}/css/${PKGNAME}.css" - @$(RM) "/usr/share/${PKGNAME}/ui/${PKGNAME}-banner.png" - @$(RM) "/usr/share/${PKGNAME}/css/${PKGNAME}.css" - @$(RM) "/usr/share/${PKGNAME}/css/${PKGNAME}.css" - @$(RM) "/usr/share/${PKGNAME}/css/${PKGNAME}.css" - @$(RM) -d "/usr/share/${PKGNAME}/css" - @$(RM) -d "/usr/share/${PKGNAME}/ui" - @$(RM) -d "/usr/share/${PKGNAME}" - @$(RM) "/etc/ubconfig-main.conf" - @gtk-update-icon-cache -fiq /usr/share/icons/hicolor/ &>/dev/null - @update-desktop-database --quiet 2>/dev/null - @touch /usr/share/applications + @$(RM) "${DESTDIR}${PREFIX}/bin/${PKGNAME}" + @$(RM) "${DESTDIR}${PREFIX}/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}" + @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; \ + [ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \ + fi @echo "Uninstall: OK" install: check uninstall @echo "Install ..." @for FILE_PO in $(wildcard *.po); do \ LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \ - install -dm755 /usr/share/locale/$${LANG}/LC_MESSAGES; \ + install -dm755 "${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES"; \ FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \ - PATH_FILE_MO="/usr/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ - echo $${FILE_PO}; \ + PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ + echo "$${FILE_PO}"; \ msgfmt "$${FILE_PO}" -v -f -o "$${PATH_FILE_MO}"; \ done @for SIZE in 16 32 48; do \ - install -dm755 /usr/share/icons/hicolor/$${SIZE}x$${SIZE}/apps; \ - rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data ${PKGNAME}.svg -o "/usr/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/${PKGNAME}.svg"; \ + 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 -Dm644 -t /usr/share/icons/hicolor/scalable/apps/ ${PKGNAME}.svg - @install -Dm755 -t /usr/bin/ ${CMAKE_BUILD_DIR}/${PKGNAME} - @install -Dm644 -t /usr/share/applications/ ${PKGNAME}.desktop - @install -Dm755 /usr/share/${PKGNAME}/ -d ui - @install -Dm755 /usr/share/${PKGNAME}/ -d css - @install -Dm644 -t /usr/share/${PKGNAME}/ui/ ${PKGNAME}.glade - @install -Dm644 -t /usr/share/${PKGNAME}/css/ ${PKGNAME}.css - @install -Dm644 -t /usr/share/${PKGNAME}/ui/ ublinux-logo.svg - @install -Dm644 -t /etc/ ubconfig-main.conf - @chmod 766 /etc/ubconfig-main.conf - @install -Dm644 -t /usr/share/${PKGNAME}/ui/ ${PKGNAME}-banner.png - @gtk-update-icon-cache -fiq /usr/share/icons/hicolor/ &>/dev/null - @update-desktop-database --quiet 2>/dev/null - @touch /usr/share/applications + @install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" + @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 -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" + @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; \ + [ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \ + fi @echo "Install: OK" clean: @@ -142,13 +137,22 @@ 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)" - @echo "... init" - @echo "... debug" - @echo "... prepare" - @echo "... compile" - @echo "... install" - @echo "... uninstall" - @echo "... clean" + @echo "The following are some of the valid targets for this Makefile:"; \ + echo "... all (the default if no target is provided)"; \ + echo "... init"; \ + echo "... debug"; \ + echo "... prepare"; \ + echo "... compile"; \ + echo "... install"; \ + echo "... uninstall"; \ + echo "... clean"; \ + echo "... up_ver" diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 6279e9e..1859049 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -9,7 +9,11 @@ link_directories(${GTK_LIBRARY_DIRS}) add_definitions(${GTK_CFLAGS_OTHER}) #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 -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 diff --git a/source/ubl-settings-manager.h b/source/ubl-settings-manager.h index b6bb96f..af8076c 100644 --- a/source/ubl-settings-manager.h +++ b/source/ubl-settings-manager.h @@ -3,24 +3,26 @@ #include #include +#include - +#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 GlobalConfigPath "/etc/ubconfig-main.conf" -#define UserConfigPath "/.config/ubl-settings-manager/ubconfig-main.conf" -#define AppIconPath "ubl-settings-manager" -#define AppBannerPath "/usr/share/ubl-settings-manager/ui/ubl-settings-manager-banner.png" +#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 DesktopPath "/usr/share/applications/" #define IconPicturesPath "/usr/share/icons/hicolor/scalable/apps/" -#define ErrIconPicturePath "/usr/share/icons/Faenza/emblems/32/emblem-important.png" -#define ublinux_logo "/usr/share/ubl-settings-manager/ui/ublinux-logo.svg" +#define ublinux_logo "/usr/share/ubl-settings-manager/images/ublinux-logo.svg" #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-manager" -#define LogoPath "/usr/share/icons/hicolor/scalable/apps/ubl-settings-manager.svg" #define ubl_settings_infoPath "ubl-settings-info" #define ubl_settings_infoPathLaunch "ubl-settings-info --socket-id=" -char *version_application = "1.3"; +typedef char* string; +string version_application = "1.2"; + typedef struct apps{ char *Name; @@ -80,6 +82,8 @@ typedef struct { char *lastUser; int changed; int fullscreen; + int lock_settings; + dictionary *SettingsSections; } config; typedef struct { @@ -137,7 +141,7 @@ typedef struct { GtkWidget *GnomePaned; GtkWidget *GnomeInfoLabel; GtkWidget *workingwindow; - // GtkWidget *settingsSectionsSettingsButton; + GtkWidget *settingsSectionsSettingsButton; GtkWidget *SectionSettingsWindow; GtkWidget *SectionSettingsPack; dictionary *SettingsSections; @@ -159,6 +163,8 @@ typedef struct { apps *applist; GtkWidget *icvpack; GtkWidget *infoWarningWindow; + GtkWidget *infoWarningButton; + GtkWidget *infoWarningLabel; } actionWidgets; @@ -197,11 +203,12 @@ void sort_apps(apps *applist,int size); apps *find_apps(int *sizef); int check_categories(apps app, char *catstocheck); int setup_config(); +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); char *yon_cut(char *source, int size, int startpos); int yon_set_sections(IconSection *section); -void yon_set_default_sections(dictionary **section); +void yon_set_default_sections(dictionary *section); char *yon_char_divide_search(char *source, char* dividepos, int delete_divider); char *yon_char_divide(char *source, int dividepos); dictionary *yon_section_new(dictionary *section, char *section_name, char *categories); @@ -209,6 +216,11 @@ void yon_switch_theme(dictionary **dict, dictionary *newone); dictionary *yon_dictionary_find(dictionary **dict, char *key); void yon_segment_show(actionWidgets *widgets, SectionSettingSegment *sgm); dictionary *yon_dictionary_create_empty(); +dictionary *yon_dictionary_rip(dictionary *dict); +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); SectionSettingSegment *yon_create_section_setting(char *name, char *categories); void yon_segments_show(actionWidgets *widgets); void yon_segments_hide(actionWidgets *widgets); @@ -216,7 +228,6 @@ void yon_dictionary_make_first(dictionary *dict); dictionary *yon_create_icon_section_list(dictionary *sections); int yon_show_icon_views(dictionary *IVS,actionWidgets *widgets); void yon_icon_size_convert(int mode); -void on_about_system(GtkWidget *button, actionWidgets *widgets); char *yon_char_new(char *chr); int launch(thread_output *thread); float yon_time_average(dictionary *times);