Makefile was completed. Config parsing algorythm redone

pull/2/head
parent b6526ece3e
commit ebb8e95813

@ -24,7 +24,7 @@ init:
depend:
@echo "Check depends ..."; \
if [ ! -f /bin/cmake ]; then \
echo "-- Depend 'cmake' not fount !"; \
echo "-- Depend 'cmake' not found !"; \
exit 1; \
fi; \
echo "Check depends: OK"
@ -49,7 +49,7 @@ check:
if [ -f ${CMAKE_BUILD_DIR}/${PKGNAME} ]; then \
echo "Check: OK"; \
else \
echo "Check: ${CMAKE_BUILD_DIR}/${PKGNAME} not fount !"; \
echo "Check: ${CMAKE_BUILD_DIR}/${PKGNAME} not found !"; \
exit 1; \
fi
@ -62,7 +62,7 @@ uninstall:
@echo "Uninstall ..."
@for SIZE in 16x16 32x32 48x48 scalable; do \
$(RM) "/usr/share/icons/hicolor/$${SIZE}/apps/${PKGNAME}.svg"; \
$(RM) "/usr/share/icons/hicolor/$${SIZE}/apps/${PKGNAME}.png"; \
$(RM) "/usr/share/"${pkgname}"/images/${PKGNAME}.png"; \
done
@for FILE_SVG in $(wildcard *.svg); do \
for SIZE in 16x16 32x32 48x48 scalable; do \
@ -77,6 +77,10 @@ uninstall:
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) "/etc/ubconfig-main.conf"
@$(RM) "~/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
@ -99,26 +103,17 @@ install: check uninstall
@install -dm755 /usr/share/icons/hicolor/scalable/apps
@install -Dm644 -t /usr/share/icons/hicolor/scalable/apps/ ${PKGNAME}.svg
@install -dm755 /usr/share/icons/hicolor/scalable/status
@install -Dm644 -t /usr/share/icons/hicolor/scalable/status/ \
status-original-red.svg \
status-original-dark.svg \
status-original-green.svg \
status-vpn-down.svg \
status-vpn-up-dark.svg \
status-vpn-up-green.svg \
status-isp-down.svg \
status-isp-up-dark.svg \
status-isp-up-green.svg \
status-rdp-down.svg \
status-rdp-up-dark.svg \
status-rdp-up-green.svg
@install -Dm755 -t /usr/bin/ ${CMAKE_BUILD_DIR}/${PKGNAME}
@install -Dm644 -t /usr/share/applications/ ${PKGNAME}.desktop
@install -Dm644 -t /usr/share/icons/hicolor/scalable/apps/ ${PKGNAME}.svg
@install -Dm644 -t /usr/share/${PKGNAME}/ui/ ${PKGNAME}.glade
@install -Dm644 -t /usr/share/${PKGNAME}/css/ ${PKGNAME}.css
@install -Dm644 -t /etc/ ubconfig-main.conf
@install -Dm655 -t ~/ ubconfig-main.conf
@install -Dm644 -t /usr/share/icons/hicolor/scalable/apps/ ${PKGNAME}.png
@gtk-update-icon-cache -fiq /usr/share/icons/hicolor/ &>/dev/null
@update-desktop-database --quiet 2>/dev/null
@touch /usr/share/applications
@echo "Install: OK"
@echo "Install: OK ${USER}"
clean:
@echo "Clean ..."

@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.7)
project(ubl-settings-manager)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED gtk+-3.0)
include_directories(${GTK_INCLUDE_DIRS})
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")
set(SOURCE_FILES
ubl-settings-manager.c
ubl-settings-manager.h)
set(LIBRARIES
${GTK_LIBRARIES}
pthread)
add_executable(ubl-settings-manager ${SOURCE_FILES})
target_link_libraries(ubl-settings-manager ${LIBRARIES})
install(TARGETS ubl-settings-manager DESTINATION bin)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,199 @@
#ifndef UBL_SETTINGS_MANAGER
#define UBL_SETTINGS_MANAGER
#include <gtk/gtk.h>
#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 "/usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg"
#define AppBannerPath "/usr/share/icons/hicolor/scalable/apps/ubl-settings-manager.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 PictureFormatMain ".svg"
#define PictureFormatExtra ".png"
#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 "/home/superadmin/Документы/ubl-settings-manager/ub-settings-manager/ubl-info/ubl-settings-info"
#define ubl_settings_infoPathLaunch "/home/superadmin/Документы/ubl-settings-manager/ub-settings-manager/ubl-info/ubl-settings-info --socket-id="
typedef struct apps{
char *Name;
int Type;
char *Categories;
char *Exec;
char *Icon;
int Pluggable;
} apps;
typedef struct dictionary {
char *key;
void *data;
struct dictionary *next;
struct dictionary *prev;
struct dictionary *first;
} dictionary;
typedef struct IVGrapgicals{
char *sectionName;
char *categories;
GtkListStore *LV;
GtkWidget *Box;
GtkWidget *IV;
GtkWidget *label;
GtkWidget *sep;
} IVGraphicals;
typedef struct IconSection{
char *section;
char *categories;
} IconSection;
typedef struct {
int windowWidth;
int windowHeight;
int windowPosX;
int windowPosY;
int WindowTheme;
char *curThemeName;
int iconsize;
int iconSegmentSize;
dictionary *sections;
} config;
typedef struct {
GtkWidget *MainFrame;
GtkWidget *MainBox;
GtkWidget *ElemBox;
GtkWidget *DragButtonBox;
GtkWidget *DragUpButton;
GtkWidget *DragDownButton;
GtkWidget *NameBox;
GtkWidget *CategoriesBox;
GtkWidget *OptionBox;
GtkWidget *NameEntry;
GtkWidget *NameLabel;
GtkWidget *CategoriesEntry;
GtkWidget *CategoriesLabel;
GtkWidget *EditButtonBox;
GtkWidget *EditButtonAccept;
GtkWidget *EditButtonCancel;
GtkWidget *ButtonEdit;
GtkWidget *ButtonDelete;
GtkWidget *DeleditBox;
} SectionSettingSegment;
typedef struct {
GtkBuilder *builder;
GtkWidget *window;
dictionary *ICSys;
GtkWidget *DesktopBasic;
GtkWidget *DesktopSocket;
GtkWidget *ButtonBackToMain;
GtkWidget *DialogOpenDocumentation;
GtkWidget *CancelHelpButton;
GtkWidget *ReadHelpButton;
GtkWidget *AlwaysOpenDocumentation;
GtkWidget *helpHeader;
GtkWidget *helpText;
GtkWidget *appSettings;
GtkWidget *SettingsWindow;
GtkWidget *settingsSizeSlider;
GtkWidget *settingsSizeInfoLabel;
GtkWidget *settingsThemeChooser;
GtkWidget *settingsCancel;
GtkWidget *settingsAccept;
GtkWidget *settingsIcon;
GtkWidget *socket;
GtkWidget *socketplace;
GtkWidget *HideWhileLaunch;
GtkWidget *MenuItemSettings;
GtkWidget *MenuItemDocumentation;
GtkWidget *MenuItemAboutSystem;
GtkWidget *LabelTitle;
GtkWidget *settingsSubmenuLabelSize;
GtkWidget *settingsSubmenuLabelTheme;
GtkWidget *GnomePaned;
GtkWidget *GnomeInfoLabel;
GtkWidget *workingwindow;
GtkWidget *settingsSectionsSettingsButton;
GtkWidget *SectionSettingsWindow;
GtkWidget *SectionSettingsPack;
dictionary *SettingsSections;
GtkWidget *SectionSettingAddButton;
GtkWidget *SectionSettingAddNameEntry;
GtkWidget *SectionSettingAddCategoriesEntry;
GtkWidget *SectionSettingsClearEntryButton;
GtkWidget *SectionSettingsSaveButton;
GtkWidget *SectionSettingsCloseButton;
GtkWidget *GnomeInfoDetailsLabel;
GtkWidget *CautionWindow;
GtkWidget *CautionUnderstandButton;
int appssize;
apps *applist;
GtkWidget *icvpack;
} actionWidgets;
typedef enum {
ACTIONWIDGETS,
ICONSECTION,
IVGRAPHICALS,
OTHER
} DICT_TYPE;
void on_plug_added(GtkSocket* self, actionWidgets *builder);
void on_plug_removed(GtkSocket* self, actionWidgets *widgets);
void on_Item_activated(GtkIconView* self, GtkTreePath* path, actionWidgets *applist);
void on_gnome_Item_activated(GtkIconView* self, GtkTreePath* path, actionWidgets *applist);
void on_item_selection_changed(GtkIconView *IV, actionWidgets *widgets);
void on_ButtonOpenHelp_activated(GtkWidget *button, GtkBuilder *builder);
void on_backToSettingsButton_clicked(GtkWidget *button,actionWidgets *sctb);
void on_CancelHelpButton_activated(GtkWidget *button,GtkBuilder *builder);
void on_ReadHelpButton_activated(GtkWidget *button, GtkBuilder *builder);
void launch_app_with_arguments(char *name, char *args);
void launch_app(char *name);
void py_launch_app(char *name,char *args);
int on_settings_accept(GtkWidget *button, dictionary **widgetsDs);
void on_paned_move(GtkPaned* self, GtkScrollType* scroll_type, actionWidgets *widgets);
int on_settingsOpen(GtkWidget *button, actionWidgets *widgets);
int on_settings_icon_size_changed(GtkWidget* self, actionWidgets *widgets);
int on_settings_cancel(GtkWidget *button, actionWidgets *widgets);
apps *get_app_by_name(apps *applist,char *name, int size);
int reload_list(IVGraphicals *section);
int load_apps(IVGraphicals *section, apps *applist, int size);
int load_apps_with_clear(IVGraphicals *section, apps *applist, int size);
int hide_if_unfound(dictionary *widgetsDc);
GtkWidget *create_socket(actionWidgets *builder);
void sort_apps(apps *applist,int size);
apps *find_apps(int *sizef);
int check_categories(apps app, char *catstocheck);
int setup_config();
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);
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);
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();
SectionSettingSegment *yon_create_section_setting(char *name, char *categories);
void yon_segments_show(actionWidgets *widgets);
void yon_segments_hide(actionWidgets *widgets);
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);
#endif

@ -15,6 +15,7 @@
#include<sys/sysinfo.h>
#include <math.h>
#include <wctype.h>
#include <sys/stat.h>
#include "ubl-settings-manager.h"
@ -163,9 +164,7 @@ int on_settings_accept(GtkWidget *button, dictionary **widgetsDs){
main_config.curThemeName="Gnome";
dictionary *widgetsD=yon_dictionary_find(widgetsDs,main_config.curThemeName);
printf("Saving config...\n");
actionWidgets *widgets=(actionWidgets*)widgetsD->data;
int theme=gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->settingsThemeChooser));
gtk_window_get_position(GTK_WINDOW(widgets->window),&main_config.windowPosX,&main_config.windowPosY);
gtk_window_get_size(GTK_WINDOW(widgets->window),&main_config.windowWidth,&main_config.windowHeight);
@ -173,20 +172,15 @@ int on_settings_accept(GtkWidget *button, dictionary **widgetsDs){
main_config.curThemeName="Main";
else if (theme==1)
main_config.curThemeName="Gnome";
if (main_config.WindowTheme!=theme){
main_config.WindowTheme=theme;
GtkWidget *loaderWindow=GTK_WIDGET(gtk_builder_get_object(widgets->builder,"LoaderWindow"));
gtk_window_resize(GTK_WINDOW(loaderWindow),main_config.windowWidth,main_config.windowHeight);
gtk_window_move(GTK_WINDOW(loaderWindow),main_config.windowPosX,main_config.windowPosY);
gtk_widget_show(loaderWindow);
// gtk_widget_hide(widgets->window);
yon_switch_theme(widgetsDs,yon_dictionary_find(&widgetsD,main_config.curThemeName));
if (widgets!=(actionWidgets*)widgetsD->data) widgets=(actionWidgets*)widgetsD->data;
// gtk_widget_show(widgets->window);
gtk_widget_hide(loaderWindow);
// main_config.WindowTheme=theme;
gtk_window_present(GTK_WINDOW(widgets->SettingsWindow));
}
GKeyFile *gfile=g_key_file_new();
@ -197,7 +191,18 @@ int on_settings_accept(GtkWidget *button, dictionary **widgetsDs){
if (main_config.iconsize==24) sz=1;
char *fromint=malloc(5);
memset(fromint,0,5);
g_key_file_load_from_file(gfile,ConfigPath,G_KEY_FILE_NONE,NULL);
GError *err=NULL;
g_key_file_load_from_file(gfile,UserConfigPath,G_KEY_FILE_NONE,&err);
if (err){
struct stat st = {0};
if (stat("~/.config/ubl-settings-manager/", &st) == -1) {
mkdir("~/.config/ubl-settings-manager/", 0777);
}
FILE *fp;
fp=fopen(UserConfigPath,"w");
fclose(fp);
}
g_key_file_load_from_file(gfile,UserConfigPath,G_KEY_FILE_NONE,&err);
sprintf(fromint,"%d",main_config.windowPosX);
g_key_file_set_string(gfile,"window","WindowPosX",fromint);
sprintf(fromint,"%d",main_config.windowPosY);
@ -217,7 +222,7 @@ int on_settings_accept(GtkWidget *button, dictionary **widgetsDs){
g_key_file_set_string(gfile,"sections",IV->sectionName,IV->categories);
load_apps_with_clear(IV,widgets->applist,widgets->appssize);
}
g_key_file_save_to_file(gfile,ConfigPath,NULL);
g_key_file_save_to_file(gfile,UserConfigPath,NULL);
gtk_widget_hide(widgets->SettingsWindow);
//gtk_window_present(GTK_WINDOW(widgets->SettingsWindow));
};
@ -486,19 +491,19 @@ void on_sections_add(GtkWidget *button, actionWidgets *widgets){
}
void on_sections_new_clear(GtkWidget *button, actionWidgets *widgets){
printf("w54y3563sthts\n");
//printf("w54y3563sthts\n");
gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddNameEntry),"");
gtk_entry_set_text(GTK_ENTRY(widgets->SectionSettingAddCategoriesEntry),"");
}
void on_sections_close(GtkWidget *button, actionWidgets *widgets){
printf("snnnnnnthtsgyuilgg\n");
//printf("snnnnnnthtsgyuilgg\n");
gtk_widget_hide(widgets->SectionSettingsWindow);
}
void on_sections_save(GtkWidget *button, actionWidgets *widgets){
GKeyFile *gfile=g_key_file_new();
g_key_file_load_from_file(gfile,ConfigPath,G_KEY_FILE_NONE,NULL);
g_key_file_load_from_file(gfile,GlobalConfigPath,G_KEY_FILE_NONE,NULL);
main_config.sections=yon_dictionary_create_empty();
for (dictionary *dict=widgets->SettingsSections;dict!=NULL;dict=dict->next){
SectionSettingSegment *segment=(SectionSettingSegment*)dict->data;
@ -511,7 +516,7 @@ void on_sections_save(GtkWidget *button, actionWidgets *widgets){
}
}
main_config.sections->next=NULL;
g_key_file_save_to_file(gfile,ConfigPath,NULL);
g_key_file_save_to_file(gfile,GlobalConfigPath,NULL);
for (dictionary *cur=widgets->ICSys->first; cur!=NULL;cur=cur->next){
IVGraphicals *IV=cur->data;
gtk_container_remove(GTK_CONTAINER(widgets->icvpack),IV->Box);
@ -781,7 +786,7 @@ apps *find_apps(int *sizef){
applist[size].Icon=malloc(strlen(tempapp.Icon)+1);
strncpy(applist[size].Name,tempapp.Name,strlen(tempapp.Name));
applist[size].Name[strlen(tempapp.Name)]='\0';
printf("%s\n",applist[size].Name);
//printf("%s\n",applist[size].Name);
strncpy(applist[size].Categories,tempapp.Categories,strlen(tempapp.Categories));
applist[size].Categories[strlen(tempapp.Categories)]='\0';
strncpy(applist[size].Exec,tempapp.Exec,strlen(tempapp.Exec));
@ -838,148 +843,55 @@ int check_categories(apps app, char *catstocheck){
};
int setup_config(){
FILE *file;
GError *err=NULL;
printf("1\n");
main_config.sections=malloc(sizeof(dictionary));
main_config.sections->data=NULL;
main_config.sections->next=NULL;
main_config.sections->prev=NULL;
main_config.sections->first=NULL;
FILE *file;
GKeyFile *configfile = g_key_file_new();
printf("%s\n",UserConfigPath);
printf("%s\n",GlobalConfigPath);
g_key_file_load_from_file(configfile,UserConfigPath,G_KEY_FILE_KEEP_TRANSLATIONS,&err);
if (err){
g_error_free(err);
err=NULL;
g_key_file_load_from_file(configfile,GlobalConfigPath,G_KEY_FILE_KEEP_TRANSLATIONS,&err);
if (err){
g_error_free(err);
return 0;
}
}
char *foroutput=NULL;
char path[100]=ConfigPath;
file=fopen(path,"r");
char *line=NULL;
if (!file) {
file=fopen(path,"w");
fclose(file);
}
file=fopen(path,"r");
fseek(file,0L,SEEK_END);
int lsize=(int)ftell(file);
if (lsize==0){
main_config.windowPosX=0;
main_config.windowPosY=0;
main_config.windowWidth=800;
main_config.windowHeight=600;
main_config.WindowTheme=0;
main_config.iconsize=32;
main_config.iconSegmentSize=150;
return 2;
}
line=malloc(lsize+1);
line[lsize]=-1;
fseek(file,0L,SEEK_SET);
fread(line,1,lsize,file);
line[lsize]='\0';
char *nmline;
char *minus;
int leng;
nmline=strstr(line,"WindowPosX=")+11;
if (nmline==0xb){main_config.windowPosX=0;}else{
minus=strstr(nmline,"\n");
if (!minus) minus="";
leng=strlen(nmline)-strlen(minus);
foroutput=malloc(leng+2);
strncpy(foroutput,nmline,leng);
foroutput[leng]='\0';
main_config.windowPosX=atoi(foroutput);
free(foroutput);
fseek(file,0L,SEEK_SET);
}
nmline=strstr(line,"WindowPosY=")+11;
if (nmline==0xb){main_config.windowPosY=0;}else{
minus=strstr(nmline,"\n");
if (!minus) minus="";
leng=strlen(nmline)-strlen(minus);
foroutput=malloc(leng+2);
strncpy(foroutput,nmline,leng);
foroutput[leng]='\0';
main_config.windowPosY=atoi(foroutput);
free(foroutput);
fseek(file,0L,SEEK_SET);
}
nmline=strstr(line,"WindowHeight=")+13;
if (nmline==0xd){main_config.windowHeight=600;}else{
minus=strstr(nmline,"\n");
if (!minus) minus="";
leng=strlen(nmline)-strlen(minus);
foroutput=malloc(leng+2);
strncpy(foroutput,nmline,leng);
foroutput[leng]='\0';
main_config.windowHeight=atoi(foroutput);
free(foroutput);
fseek(file,0L,SEEK_SET);
}
nmline=strstr(line,"WindowWidth=")+12;
if (nmline==0xd){main_config.windowWidth=800;}else{
minus=strstr(nmline,"\n");
if (!minus) minus="";
leng=strlen(nmline)-strlen(minus);
foroutput=malloc(leng+2);
strncpy(foroutput,nmline,leng);
foroutput[leng]='\0';
main_config.windowWidth=atoi(foroutput);
free(foroutput);
fseek(file,0L,SEEK_SET);
}
nmline=strstr(line,"WindowTheme=")+12;
if (nmline==0xc){main_config.WindowTheme=1;}else{
minus=strstr(nmline,"\n");
if (!minus) minus="";
foroutput=malloc(leng+2);
strncpy(foroutput,nmline,leng);
foroutput[leng]='\0';
main_config.WindowTheme=atoi(foroutput);
free(foroutput);
fseek(file,0L,SEEK_SET);
}
nmline=strstr(line,"IconSize=")+9;
if (nmline==0x9){main_config.iconsize=1;}else{
minus=strstr(nmline,"\n");
if (!minus) minus="";
leng=strlen(nmline)-strlen(minus);
foroutput=malloc(leng+2);
strncpy(foroutput,nmline,leng);
foroutput[leng]='\0';
main_config.iconsize=atoi(foroutput);
if (main_config.iconsize==1)main_config.iconsize=24;
else if (main_config.iconsize==2)main_config.iconsize=32;
else if (main_config.iconsize==3)main_config.iconsize=48;
else if (main_config.iconsize==4)main_config.iconsize=64;
free(foroutput);
fseek(file,0L,SEEK_SET);
}
nmline=strstr(line,"IconSegmentSize=")+16;
if (nmline==0x9){main_config.iconsize=1;}else{
minus=strstr(nmline,"\n");
if (!minus) minus="";
leng=strlen(nmline)-strlen(minus);
foroutput=malloc(leng+2);
strncpy(foroutput,nmline,leng);
foroutput[leng]='\0';
main_config.iconSegmentSize=atoi(foroutput);
free(foroutput);
fseek(file,0L,SEEK_SET);
}
nmline=strstr(line,"[sections]\n");
if (!nmline){yon_set_default_sections(main_config.sections);} else {
nmline+=11;
minus=strstr(nmline,"[");
if (!minus) minus="";
leng=strlen(nmline)-strlen(minus);
char *sectionsline=yon_cut(nmline,leng,0);
while (strcmp(sectionsline,"")!=0){
nmline=yon_char_divide_search(sectionsline,"\n",1);
char *name=yon_char_divide_search(nmline, "=",1);
if (strcmp(name,"")!=0 || strcmp(nmline,"")!=0)
main_config.sections=yon_section_new(main_config.sections,name, nmline);
printf("1\n");
main_config.windowPosX=g_key_file_get_integer(configfile,"window","WindowPosX",NULL);
main_config.windowPosY=g_key_file_get_integer(configfile,"window","WindowPosY",NULL);
main_config.windowWidth=g_key_file_get_integer(configfile,"window","WindowWidth",NULL);
main_config.windowHeight=g_key_file_get_integer(configfile,"window","WindowHeight",NULL);
main_config.WindowTheme=g_key_file_get_integer(configfile,"window","WindowTheme",NULL);
main_config.iconsize=g_key_file_get_integer(configfile,"window","IconSize",NULL);
main_config.iconSegmentSize=g_key_file_get_integer(configfile,"window","IconSegmentSize",NULL);
yon_icon_size_convert(0);
gsize length=0;
printf("1\n");
char **a=g_key_file_get_keys(configfile,"sections",&length,NULL);
if (!a){yon_set_default_sections(&main_config.sections);} else {
for (int i=0;i<length;i++){
char *cats=g_key_file_get_string(configfile,"sections",a[i],NULL);
main_config.sections=yon_section_new(main_config.sections,a[i], cats);
}
main_config.sections->next=NULL;
}
printf("1\n");
if (main_config.windowWidth<1024&&main_config.windowHeight<720){
main_config.WindowTheme=0;
}
return 1;
};
char *yon_cut(char *source, int size, int startpos){
char *cut=NULL;
@ -1008,38 +920,38 @@ char *yon_char_divide_search(char *source, char* dividepos, int delete_divider){
return cut;
}
void yon_set_default_sections(dictionary *section){
section=malloc(sizeof(dictionary));
void yon_set_default_sections(dictionary **section){
*section=malloc(sizeof(dictionary));
IconSection *sec=malloc(sizeof(IconSection));
sec->section="Personal";
sec->categories="X-UBL-SettingsManager;X-UBL-PersonalSettings;";
section->data=sec;
section->first=section;
section->next=malloc(sizeof(dictionary));
section->next->prev=section;
section->next->first=section->first;
section=section->next;
(*section)->data=sec;
(*section)->first=*section;
(*section)->next=malloc(sizeof(dictionary));
(*section)->next->prev=*section;
(*section)->next->first=(*section)->first;
*section=(*section)->next;
sec=malloc(sizeof(IconSection));
sec->section="Hardware";
sec->categories="X-UBL-SettingsManager;X-UBL-HardwareSettings;";
section->data=sec;
section->next=malloc(sizeof(dictionary));
section->next->prev=section;
section->next->first=section->first;
section=section->next;
(*section)->data=sec;
(*section)->next=malloc(sizeof(dictionary));
(*section)->next->prev=*section;
(*section)->next->first=(*section)->first;
*section=(*section)->next;
sec=malloc(sizeof(IconSection));
sec->section="System";
sec->categories="X-UBL-SettingsManager;X-UBL-SystemSettings;";
section->data=sec;
section->next=malloc(sizeof(dictionary));
section->next->prev=section;
section->next->first=section->first;
section=section->next;
(*section)->data=sec;
(*section)->next=malloc(sizeof(dictionary));
(*section)->next->prev=*section;
(*section)->next->first=(*section)->first;
*section=(*section)->next;
sec=malloc(sizeof(IconSection));
sec->section="Misc";
sec->categories="X-UBL-SettingsManager;";
section->data=sec;
section=section->first;
(*section)->data=sec;
*section=(*section)->first;
}
IVGraphicals *yon_create_single_section_IV(char *name,char *cats){
@ -1078,6 +990,8 @@ IVGraphicals *yon_create_single_section_IV(char *name,char *cats){
}
dictionary *yon_create_icon_section_list(dictionary *sections){
if (!sections)
return NULL;
IVGraphicals *IVSections;
dictionary *IVDict=NULL;
sections=sections->first;
@ -1104,6 +1018,14 @@ dictionary *yon_create_icon_section_list(dictionary *sections){
return IVDict->first;
}
void yon_check_path(char *path){
FILE *fp;
char *pth=malloc(255);
memset(path,0,255);
fp = popen("screenfetch -n -w -N", "r");
fgets(pth, 255,fp)!=NULL;
}
dictionary *yon_section_new(dictionary *section, char *section_name, char *categories){
section->next=NULL;
IconSection *sct=malloc(sizeof(IconSection));
@ -1218,6 +1140,21 @@ void yon_switch_theme(dictionary **dict, dictionary *newone){
}
void yon_icon_size_convert(int mode){
if (mode==0){
if (main_config.iconsize==1) main_config.iconsize=24;
if (main_config.iconsize==2) main_config.iconsize=32;
if (main_config.iconsize==3) main_config.iconsize=48;
if (main_config.iconsize==4) main_config.iconsize=64;
} else if (mode==1){
if (main_config.iconsize==24) main_config.iconsize=1;
if (main_config.iconsize==32) main_config.iconsize=2;
if (main_config.iconsize==48) main_config.iconsize=3;
if (main_config.iconsize==64) main_config.iconsize=4;
}
}
SectionSettingSegment *yon_create_section_setting(char *name, char *categories){
SectionSettingSegment *segment=malloc(sizeof(SectionSettingSegment));
segment->MainFrame=gtk_frame_new(NULL);
@ -1489,7 +1426,10 @@ dictionary *yon_theme_new(dictionary **widgetss, GtkBuilder *builder, char *them
int main(int argc, char *argv[]){
gtk_init(&argc, &argv);
setup_config();
if (setup_config()==0){
printf("Ошибка загрузки конфига!\n");
return -1;
}
local=setlocale(LC_ALL, "");
bindtextdomain (LocaleName, LocalePath);
textdomain (LocaleName);

@ -10,5 +10,5 @@ Type=Application
Exec=ubl-settings-manager
Icon=ublinux-ubconfig
Terminal=false
Pluggable=false
X-XfcePluggable=false
Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;

@ -628,7 +628,7 @@
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixbuf">../../../../../../usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg</property>
<property name="pixbuf">../../../../usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg</property>
<property name="icon_size">6</property>
</object>
<object class="GtkMenu" id="PersonalMenu">
@ -1238,7 +1238,7 @@
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixbuf">../../../../../../usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg</property>
<property name="pixbuf">../../../../usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg</property>
<property name="icon_size">5</property>
</object>
</child>
@ -1429,7 +1429,7 @@
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixbuf">../../../../../../usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg</property>
<property name="pixbuf">../../../../usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg</property>
<property name="icon_size">5</property>
</object>
</child>
@ -1632,7 +1632,7 @@
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixbuf">../../../../../../usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg</property>
<property name="pixbuf">../../../../usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg</property>
<property name="icon_size">5</property>
</object>
</child>

@ -3,9 +3,10 @@
#include <gtk/gtk.h>
#define GladePath "ui/ubl-settings-manager.glade"
#define CssPath "./css/ubl-settings-manager.css"
#define ConfigPath ".config/ubconfig-main/ubconfig-main.conf"
#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 "/usr/share/icons/hicolor/32x32/apps/ublinux-ubconfig.svg"
#define AppBannerPath "/usr/share/icons/hicolor/scalable/apps/ubl-settings-manager.png"
#define DesktopPath "/usr/share/applications/"
@ -13,8 +14,8 @@
#define ErrIconPicturePath "/usr/share/icons/Faenza/emblems/32/emblem-important.png"
#define PictureFormatMain ".svg"
#define PictureFormatExtra ".png"
#define LocalePath "/usr/share/locale/"
#define LocaleName "base"
#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 "/home/superadmin/Документы/ubl-settings-manager/ub-settings-manager/ubl-info/ubl-settings-info"
#define ubl_settings_infoPathLaunch "/home/superadmin/Документы/ubl-settings-manager/ub-settings-manager/ubl-info/ubl-settings-info --socket-id="
@ -180,7 +181,7 @@ dictionary *yon_theme_new(dictionary **widgetss, GtkBuilder *builder, char *them
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);
@ -194,4 +195,5 @@ void yon_segments_hide(actionWidgets *widgets);
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);
#endif
Loading…
Cancel
Save