Fixed config loading. Fixed config saving.

pull/2/head
parent ebb8e95813
commit cbf10ec362

@ -108,7 +108,8 @@ install: check uninstall
@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
chmod 766 /etc/ubconfig-main.conf
@install -Dm655 -t ~/.config/ 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

@ -19,6 +19,12 @@ set(LIBRARIES
${GTK_LIBRARIES}
pthread)
add_custom_target(glade ALL
COMMAND cmake -E copy_directory ${CMAKE_SOURCE_DIR}/ui ${CMAKE_BINARY_DIR}/ui
)
add_custom_target(css ALL
COMMAND cmake -E copy_directory ${CMAKE_SOURCE_DIR}/css ${CMAKE_BINARY_DIR}/css
)
add_executable(ubl-settings-manager ${SOURCE_FILES})
target_link_libraries(ubl-settings-manager ${LIBRARIES})
install(TARGETS ubl-settings-manager DESTINATION bin)

@ -192,17 +192,21 @@ int on_settings_accept(GtkWidget *button, dictionary **widgetsDs){
char *fromint=malloc(5);
memset(fromint,0,5);
GError *err=NULL;
g_key_file_load_from_file(gfile,UserConfigPath,G_KEY_FILE_NONE,&err);
char *pth=malloc(7+strlen(UserConfigPath)+strlen(getlogin()));
sprintf(pth,"%s%s%s","/home/",getlogin(),UserConfigPath);
g_key_file_load_from_file(gfile,pth,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);
char *ptdir=malloc(36+strlen(getlogin()));
sprintf(ptdir,"%s%s%s","/home/",getlogin(),"/.config/ubl-settings-manager");
if (stat(ptdir, &st) == -1) {
mkdir(ptdir, 0777);
}
FILE *fp;
fp=fopen(UserConfigPath,"w");
fp=fopen(pth,"w");
fclose(fp);
}
g_key_file_load_from_file(gfile,UserConfigPath,G_KEY_FILE_NONE,&err);
g_key_file_load_from_file(gfile,pth,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);
@ -222,7 +226,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,UserConfigPath,NULL);
g_key_file_save_to_file(gfile,pth,NULL);
gtk_widget_hide(widgets->SettingsWindow);
//gtk_window_present(GTK_WINDOW(widgets->SettingsWindow));
};
@ -852,9 +856,12 @@ int setup_config(){
main_config.sections->prev=NULL;
main_config.sections->first=NULL;
GKeyFile *configfile = g_key_file_new();
printf("%s\n",UserConfigPath);
char *pth=malloc(7+strlen(UserConfigPath)+strlen(getlogin()));
sprintf(pth,"%s%s%s","/home/",getlogin(),UserConfigPath);
printf("%s\n",getlogin());
printf("%s\n",pth);
printf("%s\n",GlobalConfigPath);
g_key_file_load_from_file(configfile,UserConfigPath,G_KEY_FILE_KEEP_TRANSLATIONS,&err);
g_key_file_load_from_file(configfile,pth,G_KEY_FILE_KEEP_TRANSLATIONS,&err);
if (err){
g_error_free(err);
err=NULL;

@ -6,7 +6,7 @@
#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 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/"

@ -0,0 +1,14 @@
[window]
WindowPosX=0
WindowPosY=0
WindowWidth=1920
WindowHeight=1004
WindowTheme=0
IconSize=2
IconSegmentSize=321
[sections]
Personal=XFCE;
Hardware=X-UBL-SettingsManager;X-UBL-HardwareSettings;
System=X-UBL-SettingsManager;X-UBL-SystemSettings;
Misc=
Loading…
Cancel
Save