gtk ERROR MESSAGE Key file contains line which is not a key-value pair, group, or comment
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
The problem I'm having with this function is that it gets the following error if there is an error in the gtk keyfile. It literally jumps out of the function dumping back to the command line.
ERROR MESSAGE Key file contains line ""./icon.ico"" which is not a key-value pair, group, or comment
iconFile=
"./icon.ico"
But this is ok and it works without getting an error
iconFile="./icon.ico"
I've searched the internet but unable to fine anything relating to this error. I tried running it through gdb and valgrind but was unable to spot an error.
Can someone shed some light on what I'm doing wrong?
// *** config.c ***
// gcc -Wall -Wextra -o config config.c `pkg-config --cflags --libs gtk+-3.0`
#include <gtk/gtk.h>
#include <glib.h>
//#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
extern gchar *__progname;
int myErrorCheck(gchar **myData);
// create / get CONFIG file configuration
int main(int argc, gchar *argv)
{
// THESE ARE CONFIG FILE DEFAULT SETTINGS
// MPD HOST SETTINGS
gchar *mpdHostname = "localhost";
gint mpdPortnumber = 6600;
gint mpdTimeout = 30000;
// PLAYLIST SETTINGS
gchar *rowFont = ""Bold 16"";
gchar *viewColor = ""medium slate blue"";
gchar *textColor = ""black"";
// OTHER SETTINGS
gchar *windowTitle = "Selecet MPD Playlist";
gchar *iconFile = ""./icon.ico"";
// COMMENTS
// this comment goes above MpdHostSettings group header
gconstpointer HostSettingsComment = " These are the MPD Host parameters for this executable.";
// this comment goes above PlayListSettings group header
gconstpointer PlayListSettingsComment = " These are the MPD Playlist executable parameters.n Enclose each parameter in quotes ("")";
// this comment goes above windowTitle in Other group header
gconstpointer windowTitleComment = " This is the window title.";
// this comment goes above iconFile in Other group header
gconstpointer iconFileComment = " This is the window icon.";
// *** End of THESE ARE CONFIG FILE DEFAULT SETTINGS ***
GKeyFile *key_file;
GError *error;
key_file = g_key_file_new();
error = NULL;
gchar *cfgFile;
gchar *confPath;
// *** COPY LOWER CASE __progname AS UPPER CASE into upper__progname
gchar *upper__progname = g_ascii_strup(__progname, strlen(__progname));
// *** TEST or CREATE (if needed) the user config file PATHNAME (should be ~/.config/PROGNAME)
// build the config path string
confPath = g_strconcat(g_get_user_config_dir(),"/", upper__progname,NULL);
cfgFile = g_strconcat(confPath,"/", __progname,".conf",NULL);
// Does the config path exist? This IS a CRITICAL error.
if(access(confPath,F_OK | R_OK)) {
fprintf (stderr, "WARNING: Error opening config path %s : %s. Line number %dn", confPath, strerror(errno), __LINE__);
// if possible create PATH directory if it does not exist
if(mkdir (confPath,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1) {
g_print("Line %dn", __LINE__);
// should it for some reason not be created
fprintf (stderr, "Critical: Error creating config path %s : %s. Line number %dn", confPath, strerror(errno), __LINE__);
exit(errno);
}
// WRITE THE DEFAULT CONFIGURATION TO FILE IF CONF FILE HAS TO BE CREATED
// MPD HOST SETTINGS
g_key_file_set_string(key_file, "MpdHostSettings", "mpdHostname", mpdHostname);
g_key_file_set_integer(key_file, "MpdHostSettings", "mpdPortnumber", mpdPortnumber);
g_key_file_set_integer(key_file, "MpdHostSettings", "mpdTimeout", mpdTimeout);
// PLAYLIST SETTINGS
g_key_file_set_string(key_file, "PlayListSettings", "rowFont", rowFont);
g_key_file_set_string(key_file, "PlayListSettings", "viewColor", viewColor);
g_key_file_set_string(key_file, "PlayListSettings", "textColor", textColor);
// OTHER PARAMETERS
g_key_file_set_string(key_file, "OtherSettings", "windowTitle", windowTitle);
g_key_file_set_string(key_file, "OtherSettings", "iconFile", iconFile);
// COMMENTS
g_key_file_set_comment(key_file, "PlayListSettings", NULL, PlayListSettingsComment, NULL);
g_key_file_set_comment(key_file, "MpdHostSettings", NULL, HostSettingsComment, NULL);
g_key_file_set_comment(key_file, "OtherSettings", "windowTitle", windowTitleComment, NULL);
g_key_file_set_comment(key_file, "OtherSettings", "iconFile", iconFileComment, NULL);
//*********************************************************************
// SAVE them to to file
g_key_file_save_to_file (key_file, cfgFile, &error);
} // End of CREATE CFG FILE
// LOAD THE KEYS FROM CONF FILE IF THEIR IS NO ERROR
if(!g_key_file_load_from_file(key_file, cfgFile, G_KEY_FILE_KEEP_COMMENTS, &error))
{
printf("ERROR MESSAGE %sn", error->message);
g_debug("%s", error->message);
g_key_file_free (key_file);
return 1;
}
// MPD HOST PARAMETERS
mpdHostname = g_key_file_get_string(key_file, "MpdHostSettings", "mpdHostname", &error);
mpdPortnumber = g_key_file_get_integer(key_file, "MpdHostSettings", "mpdPortnumber", &error);
mpdTimeout = g_key_file_get_integer(key_file, "MpdHostSettings", "mpdTimeout", &error);
// MPD PLAYLIST PARAMETERS
rowFont = g_key_file_get_string(key_file, "PlayListSettings", "rowFont", &error);
viewColor = g_key_file_get_string(key_file, "PlayListSettings", "viewColor", &error);
textColor = g_key_file_get_string(key_file, "PlayListSettings", "textColor", &error);
windowTitle = g_key_file_get_string(key_file, "OtherSettings", "windowTitle", &error);
iconFile = g_key_file_get_string(key_file, "OtherSettings", "iconFile", &error);
// *** PRINT THESE VARIABLES ***
// MPD HOST SETTINGS
g_print("mpdHostname %sn",mpdHostname);
g_print("mpdPortnumber %dn", mpdPortnumber) ;
g_print("mpdTimeout %dn", mpdTimeout);
// PLAYLIST SETTINGS
g_print("rowFont %sn", rowFont);
g_print("viewColor %sn", viewColor);
g_print("textColor %sn", textColor);
g_print("windowTitle %sn", windowTitle);
g_print("iconFile %sn", iconFile);
g_key_file_free (key_file);
g_free(error);
g_free(cfgFile);
g_free(mpdHostname );
//g_free(mpdPortnumber );
//g_free(mpdTimeout );
g_free(rowFont );
g_free(viewColor );
g_free(textColor );
g_free(windowTitle );
g_free(iconFile );
return 0;
}
gtk
add a comment |
The problem I'm having with this function is that it gets the following error if there is an error in the gtk keyfile. It literally jumps out of the function dumping back to the command line.
ERROR MESSAGE Key file contains line ""./icon.ico"" which is not a key-value pair, group, or comment
iconFile=
"./icon.ico"
But this is ok and it works without getting an error
iconFile="./icon.ico"
I've searched the internet but unable to fine anything relating to this error. I tried running it through gdb and valgrind but was unable to spot an error.
Can someone shed some light on what I'm doing wrong?
// *** config.c ***
// gcc -Wall -Wextra -o config config.c `pkg-config --cflags --libs gtk+-3.0`
#include <gtk/gtk.h>
#include <glib.h>
//#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
extern gchar *__progname;
int myErrorCheck(gchar **myData);
// create / get CONFIG file configuration
int main(int argc, gchar *argv)
{
// THESE ARE CONFIG FILE DEFAULT SETTINGS
// MPD HOST SETTINGS
gchar *mpdHostname = "localhost";
gint mpdPortnumber = 6600;
gint mpdTimeout = 30000;
// PLAYLIST SETTINGS
gchar *rowFont = ""Bold 16"";
gchar *viewColor = ""medium slate blue"";
gchar *textColor = ""black"";
// OTHER SETTINGS
gchar *windowTitle = "Selecet MPD Playlist";
gchar *iconFile = ""./icon.ico"";
// COMMENTS
// this comment goes above MpdHostSettings group header
gconstpointer HostSettingsComment = " These are the MPD Host parameters for this executable.";
// this comment goes above PlayListSettings group header
gconstpointer PlayListSettingsComment = " These are the MPD Playlist executable parameters.n Enclose each parameter in quotes ("")";
// this comment goes above windowTitle in Other group header
gconstpointer windowTitleComment = " This is the window title.";
// this comment goes above iconFile in Other group header
gconstpointer iconFileComment = " This is the window icon.";
// *** End of THESE ARE CONFIG FILE DEFAULT SETTINGS ***
GKeyFile *key_file;
GError *error;
key_file = g_key_file_new();
error = NULL;
gchar *cfgFile;
gchar *confPath;
// *** COPY LOWER CASE __progname AS UPPER CASE into upper__progname
gchar *upper__progname = g_ascii_strup(__progname, strlen(__progname));
// *** TEST or CREATE (if needed) the user config file PATHNAME (should be ~/.config/PROGNAME)
// build the config path string
confPath = g_strconcat(g_get_user_config_dir(),"/", upper__progname,NULL);
cfgFile = g_strconcat(confPath,"/", __progname,".conf",NULL);
// Does the config path exist? This IS a CRITICAL error.
if(access(confPath,F_OK | R_OK)) {
fprintf (stderr, "WARNING: Error opening config path %s : %s. Line number %dn", confPath, strerror(errno), __LINE__);
// if possible create PATH directory if it does not exist
if(mkdir (confPath,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1) {
g_print("Line %dn", __LINE__);
// should it for some reason not be created
fprintf (stderr, "Critical: Error creating config path %s : %s. Line number %dn", confPath, strerror(errno), __LINE__);
exit(errno);
}
// WRITE THE DEFAULT CONFIGURATION TO FILE IF CONF FILE HAS TO BE CREATED
// MPD HOST SETTINGS
g_key_file_set_string(key_file, "MpdHostSettings", "mpdHostname", mpdHostname);
g_key_file_set_integer(key_file, "MpdHostSettings", "mpdPortnumber", mpdPortnumber);
g_key_file_set_integer(key_file, "MpdHostSettings", "mpdTimeout", mpdTimeout);
// PLAYLIST SETTINGS
g_key_file_set_string(key_file, "PlayListSettings", "rowFont", rowFont);
g_key_file_set_string(key_file, "PlayListSettings", "viewColor", viewColor);
g_key_file_set_string(key_file, "PlayListSettings", "textColor", textColor);
// OTHER PARAMETERS
g_key_file_set_string(key_file, "OtherSettings", "windowTitle", windowTitle);
g_key_file_set_string(key_file, "OtherSettings", "iconFile", iconFile);
// COMMENTS
g_key_file_set_comment(key_file, "PlayListSettings", NULL, PlayListSettingsComment, NULL);
g_key_file_set_comment(key_file, "MpdHostSettings", NULL, HostSettingsComment, NULL);
g_key_file_set_comment(key_file, "OtherSettings", "windowTitle", windowTitleComment, NULL);
g_key_file_set_comment(key_file, "OtherSettings", "iconFile", iconFileComment, NULL);
//*********************************************************************
// SAVE them to to file
g_key_file_save_to_file (key_file, cfgFile, &error);
} // End of CREATE CFG FILE
// LOAD THE KEYS FROM CONF FILE IF THEIR IS NO ERROR
if(!g_key_file_load_from_file(key_file, cfgFile, G_KEY_FILE_KEEP_COMMENTS, &error))
{
printf("ERROR MESSAGE %sn", error->message);
g_debug("%s", error->message);
g_key_file_free (key_file);
return 1;
}
// MPD HOST PARAMETERS
mpdHostname = g_key_file_get_string(key_file, "MpdHostSettings", "mpdHostname", &error);
mpdPortnumber = g_key_file_get_integer(key_file, "MpdHostSettings", "mpdPortnumber", &error);
mpdTimeout = g_key_file_get_integer(key_file, "MpdHostSettings", "mpdTimeout", &error);
// MPD PLAYLIST PARAMETERS
rowFont = g_key_file_get_string(key_file, "PlayListSettings", "rowFont", &error);
viewColor = g_key_file_get_string(key_file, "PlayListSettings", "viewColor", &error);
textColor = g_key_file_get_string(key_file, "PlayListSettings", "textColor", &error);
windowTitle = g_key_file_get_string(key_file, "OtherSettings", "windowTitle", &error);
iconFile = g_key_file_get_string(key_file, "OtherSettings", "iconFile", &error);
// *** PRINT THESE VARIABLES ***
// MPD HOST SETTINGS
g_print("mpdHostname %sn",mpdHostname);
g_print("mpdPortnumber %dn", mpdPortnumber) ;
g_print("mpdTimeout %dn", mpdTimeout);
// PLAYLIST SETTINGS
g_print("rowFont %sn", rowFont);
g_print("viewColor %sn", viewColor);
g_print("textColor %sn", textColor);
g_print("windowTitle %sn", windowTitle);
g_print("iconFile %sn", iconFile);
g_key_file_free (key_file);
g_free(error);
g_free(cfgFile);
g_free(mpdHostname );
//g_free(mpdPortnumber );
//g_free(mpdTimeout );
g_free(rowFont );
g_free(viewColor );
g_free(textColor );
g_free(windowTitle );
g_free(iconFile );
return 0;
}
gtk
1
First question comment: It is great that you've provided an example of the problem, and in future it would be more useful if the example just focussed on the error, not the whole program. Your program didn't contain the line that is in error, it appears to be from a different file.
– Ron Dunn
Nov 24 '18 at 0:44
add a comment |
The problem I'm having with this function is that it gets the following error if there is an error in the gtk keyfile. It literally jumps out of the function dumping back to the command line.
ERROR MESSAGE Key file contains line ""./icon.ico"" which is not a key-value pair, group, or comment
iconFile=
"./icon.ico"
But this is ok and it works without getting an error
iconFile="./icon.ico"
I've searched the internet but unable to fine anything relating to this error. I tried running it through gdb and valgrind but was unable to spot an error.
Can someone shed some light on what I'm doing wrong?
// *** config.c ***
// gcc -Wall -Wextra -o config config.c `pkg-config --cflags --libs gtk+-3.0`
#include <gtk/gtk.h>
#include <glib.h>
//#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
extern gchar *__progname;
int myErrorCheck(gchar **myData);
// create / get CONFIG file configuration
int main(int argc, gchar *argv)
{
// THESE ARE CONFIG FILE DEFAULT SETTINGS
// MPD HOST SETTINGS
gchar *mpdHostname = "localhost";
gint mpdPortnumber = 6600;
gint mpdTimeout = 30000;
// PLAYLIST SETTINGS
gchar *rowFont = ""Bold 16"";
gchar *viewColor = ""medium slate blue"";
gchar *textColor = ""black"";
// OTHER SETTINGS
gchar *windowTitle = "Selecet MPD Playlist";
gchar *iconFile = ""./icon.ico"";
// COMMENTS
// this comment goes above MpdHostSettings group header
gconstpointer HostSettingsComment = " These are the MPD Host parameters for this executable.";
// this comment goes above PlayListSettings group header
gconstpointer PlayListSettingsComment = " These are the MPD Playlist executable parameters.n Enclose each parameter in quotes ("")";
// this comment goes above windowTitle in Other group header
gconstpointer windowTitleComment = " This is the window title.";
// this comment goes above iconFile in Other group header
gconstpointer iconFileComment = " This is the window icon.";
// *** End of THESE ARE CONFIG FILE DEFAULT SETTINGS ***
GKeyFile *key_file;
GError *error;
key_file = g_key_file_new();
error = NULL;
gchar *cfgFile;
gchar *confPath;
// *** COPY LOWER CASE __progname AS UPPER CASE into upper__progname
gchar *upper__progname = g_ascii_strup(__progname, strlen(__progname));
// *** TEST or CREATE (if needed) the user config file PATHNAME (should be ~/.config/PROGNAME)
// build the config path string
confPath = g_strconcat(g_get_user_config_dir(),"/", upper__progname,NULL);
cfgFile = g_strconcat(confPath,"/", __progname,".conf",NULL);
// Does the config path exist? This IS a CRITICAL error.
if(access(confPath,F_OK | R_OK)) {
fprintf (stderr, "WARNING: Error opening config path %s : %s. Line number %dn", confPath, strerror(errno), __LINE__);
// if possible create PATH directory if it does not exist
if(mkdir (confPath,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1) {
g_print("Line %dn", __LINE__);
// should it for some reason not be created
fprintf (stderr, "Critical: Error creating config path %s : %s. Line number %dn", confPath, strerror(errno), __LINE__);
exit(errno);
}
// WRITE THE DEFAULT CONFIGURATION TO FILE IF CONF FILE HAS TO BE CREATED
// MPD HOST SETTINGS
g_key_file_set_string(key_file, "MpdHostSettings", "mpdHostname", mpdHostname);
g_key_file_set_integer(key_file, "MpdHostSettings", "mpdPortnumber", mpdPortnumber);
g_key_file_set_integer(key_file, "MpdHostSettings", "mpdTimeout", mpdTimeout);
// PLAYLIST SETTINGS
g_key_file_set_string(key_file, "PlayListSettings", "rowFont", rowFont);
g_key_file_set_string(key_file, "PlayListSettings", "viewColor", viewColor);
g_key_file_set_string(key_file, "PlayListSettings", "textColor", textColor);
// OTHER PARAMETERS
g_key_file_set_string(key_file, "OtherSettings", "windowTitle", windowTitle);
g_key_file_set_string(key_file, "OtherSettings", "iconFile", iconFile);
// COMMENTS
g_key_file_set_comment(key_file, "PlayListSettings", NULL, PlayListSettingsComment, NULL);
g_key_file_set_comment(key_file, "MpdHostSettings", NULL, HostSettingsComment, NULL);
g_key_file_set_comment(key_file, "OtherSettings", "windowTitle", windowTitleComment, NULL);
g_key_file_set_comment(key_file, "OtherSettings", "iconFile", iconFileComment, NULL);
//*********************************************************************
// SAVE them to to file
g_key_file_save_to_file (key_file, cfgFile, &error);
} // End of CREATE CFG FILE
// LOAD THE KEYS FROM CONF FILE IF THEIR IS NO ERROR
if(!g_key_file_load_from_file(key_file, cfgFile, G_KEY_FILE_KEEP_COMMENTS, &error))
{
printf("ERROR MESSAGE %sn", error->message);
g_debug("%s", error->message);
g_key_file_free (key_file);
return 1;
}
// MPD HOST PARAMETERS
mpdHostname = g_key_file_get_string(key_file, "MpdHostSettings", "mpdHostname", &error);
mpdPortnumber = g_key_file_get_integer(key_file, "MpdHostSettings", "mpdPortnumber", &error);
mpdTimeout = g_key_file_get_integer(key_file, "MpdHostSettings", "mpdTimeout", &error);
// MPD PLAYLIST PARAMETERS
rowFont = g_key_file_get_string(key_file, "PlayListSettings", "rowFont", &error);
viewColor = g_key_file_get_string(key_file, "PlayListSettings", "viewColor", &error);
textColor = g_key_file_get_string(key_file, "PlayListSettings", "textColor", &error);
windowTitle = g_key_file_get_string(key_file, "OtherSettings", "windowTitle", &error);
iconFile = g_key_file_get_string(key_file, "OtherSettings", "iconFile", &error);
// *** PRINT THESE VARIABLES ***
// MPD HOST SETTINGS
g_print("mpdHostname %sn",mpdHostname);
g_print("mpdPortnumber %dn", mpdPortnumber) ;
g_print("mpdTimeout %dn", mpdTimeout);
// PLAYLIST SETTINGS
g_print("rowFont %sn", rowFont);
g_print("viewColor %sn", viewColor);
g_print("textColor %sn", textColor);
g_print("windowTitle %sn", windowTitle);
g_print("iconFile %sn", iconFile);
g_key_file_free (key_file);
g_free(error);
g_free(cfgFile);
g_free(mpdHostname );
//g_free(mpdPortnumber );
//g_free(mpdTimeout );
g_free(rowFont );
g_free(viewColor );
g_free(textColor );
g_free(windowTitle );
g_free(iconFile );
return 0;
}
gtk
The problem I'm having with this function is that it gets the following error if there is an error in the gtk keyfile. It literally jumps out of the function dumping back to the command line.
ERROR MESSAGE Key file contains line ""./icon.ico"" which is not a key-value pair, group, or comment
iconFile=
"./icon.ico"
But this is ok and it works without getting an error
iconFile="./icon.ico"
I've searched the internet but unable to fine anything relating to this error. I tried running it through gdb and valgrind but was unable to spot an error.
Can someone shed some light on what I'm doing wrong?
// *** config.c ***
// gcc -Wall -Wextra -o config config.c `pkg-config --cflags --libs gtk+-3.0`
#include <gtk/gtk.h>
#include <glib.h>
//#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
extern gchar *__progname;
int myErrorCheck(gchar **myData);
// create / get CONFIG file configuration
int main(int argc, gchar *argv)
{
// THESE ARE CONFIG FILE DEFAULT SETTINGS
// MPD HOST SETTINGS
gchar *mpdHostname = "localhost";
gint mpdPortnumber = 6600;
gint mpdTimeout = 30000;
// PLAYLIST SETTINGS
gchar *rowFont = ""Bold 16"";
gchar *viewColor = ""medium slate blue"";
gchar *textColor = ""black"";
// OTHER SETTINGS
gchar *windowTitle = "Selecet MPD Playlist";
gchar *iconFile = ""./icon.ico"";
// COMMENTS
// this comment goes above MpdHostSettings group header
gconstpointer HostSettingsComment = " These are the MPD Host parameters for this executable.";
// this comment goes above PlayListSettings group header
gconstpointer PlayListSettingsComment = " These are the MPD Playlist executable parameters.n Enclose each parameter in quotes ("")";
// this comment goes above windowTitle in Other group header
gconstpointer windowTitleComment = " This is the window title.";
// this comment goes above iconFile in Other group header
gconstpointer iconFileComment = " This is the window icon.";
// *** End of THESE ARE CONFIG FILE DEFAULT SETTINGS ***
GKeyFile *key_file;
GError *error;
key_file = g_key_file_new();
error = NULL;
gchar *cfgFile;
gchar *confPath;
// *** COPY LOWER CASE __progname AS UPPER CASE into upper__progname
gchar *upper__progname = g_ascii_strup(__progname, strlen(__progname));
// *** TEST or CREATE (if needed) the user config file PATHNAME (should be ~/.config/PROGNAME)
// build the config path string
confPath = g_strconcat(g_get_user_config_dir(),"/", upper__progname,NULL);
cfgFile = g_strconcat(confPath,"/", __progname,".conf",NULL);
// Does the config path exist? This IS a CRITICAL error.
if(access(confPath,F_OK | R_OK)) {
fprintf (stderr, "WARNING: Error opening config path %s : %s. Line number %dn", confPath, strerror(errno), __LINE__);
// if possible create PATH directory if it does not exist
if(mkdir (confPath,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1) {
g_print("Line %dn", __LINE__);
// should it for some reason not be created
fprintf (stderr, "Critical: Error creating config path %s : %s. Line number %dn", confPath, strerror(errno), __LINE__);
exit(errno);
}
// WRITE THE DEFAULT CONFIGURATION TO FILE IF CONF FILE HAS TO BE CREATED
// MPD HOST SETTINGS
g_key_file_set_string(key_file, "MpdHostSettings", "mpdHostname", mpdHostname);
g_key_file_set_integer(key_file, "MpdHostSettings", "mpdPortnumber", mpdPortnumber);
g_key_file_set_integer(key_file, "MpdHostSettings", "mpdTimeout", mpdTimeout);
// PLAYLIST SETTINGS
g_key_file_set_string(key_file, "PlayListSettings", "rowFont", rowFont);
g_key_file_set_string(key_file, "PlayListSettings", "viewColor", viewColor);
g_key_file_set_string(key_file, "PlayListSettings", "textColor", textColor);
// OTHER PARAMETERS
g_key_file_set_string(key_file, "OtherSettings", "windowTitle", windowTitle);
g_key_file_set_string(key_file, "OtherSettings", "iconFile", iconFile);
// COMMENTS
g_key_file_set_comment(key_file, "PlayListSettings", NULL, PlayListSettingsComment, NULL);
g_key_file_set_comment(key_file, "MpdHostSettings", NULL, HostSettingsComment, NULL);
g_key_file_set_comment(key_file, "OtherSettings", "windowTitle", windowTitleComment, NULL);
g_key_file_set_comment(key_file, "OtherSettings", "iconFile", iconFileComment, NULL);
//*********************************************************************
// SAVE them to to file
g_key_file_save_to_file (key_file, cfgFile, &error);
} // End of CREATE CFG FILE
// LOAD THE KEYS FROM CONF FILE IF THEIR IS NO ERROR
if(!g_key_file_load_from_file(key_file, cfgFile, G_KEY_FILE_KEEP_COMMENTS, &error))
{
printf("ERROR MESSAGE %sn", error->message);
g_debug("%s", error->message);
g_key_file_free (key_file);
return 1;
}
// MPD HOST PARAMETERS
mpdHostname = g_key_file_get_string(key_file, "MpdHostSettings", "mpdHostname", &error);
mpdPortnumber = g_key_file_get_integer(key_file, "MpdHostSettings", "mpdPortnumber", &error);
mpdTimeout = g_key_file_get_integer(key_file, "MpdHostSettings", "mpdTimeout", &error);
// MPD PLAYLIST PARAMETERS
rowFont = g_key_file_get_string(key_file, "PlayListSettings", "rowFont", &error);
viewColor = g_key_file_get_string(key_file, "PlayListSettings", "viewColor", &error);
textColor = g_key_file_get_string(key_file, "PlayListSettings", "textColor", &error);
windowTitle = g_key_file_get_string(key_file, "OtherSettings", "windowTitle", &error);
iconFile = g_key_file_get_string(key_file, "OtherSettings", "iconFile", &error);
// *** PRINT THESE VARIABLES ***
// MPD HOST SETTINGS
g_print("mpdHostname %sn",mpdHostname);
g_print("mpdPortnumber %dn", mpdPortnumber) ;
g_print("mpdTimeout %dn", mpdTimeout);
// PLAYLIST SETTINGS
g_print("rowFont %sn", rowFont);
g_print("viewColor %sn", viewColor);
g_print("textColor %sn", textColor);
g_print("windowTitle %sn", windowTitle);
g_print("iconFile %sn", iconFile);
g_key_file_free (key_file);
g_free(error);
g_free(cfgFile);
g_free(mpdHostname );
//g_free(mpdPortnumber );
//g_free(mpdTimeout );
g_free(rowFont );
g_free(viewColor );
g_free(textColor );
g_free(windowTitle );
g_free(iconFile );
return 0;
}
gtk
gtk
edited Nov 23 '18 at 23:12
maihoaomv
asked Nov 23 '18 at 23:02
maihoaomvmaihoaomv
12
12
1
First question comment: It is great that you've provided an example of the problem, and in future it would be more useful if the example just focussed on the error, not the whole program. Your program didn't contain the line that is in error, it appears to be from a different file.
– Ron Dunn
Nov 24 '18 at 0:44
add a comment |
1
First question comment: It is great that you've provided an example of the problem, and in future it would be more useful if the example just focussed on the error, not the whole program. Your program didn't contain the line that is in error, it appears to be from a different file.
– Ron Dunn
Nov 24 '18 at 0:44
1
1
First question comment: It is great that you've provided an example of the problem, and in future it would be more useful if the example just focussed on the error, not the whole program. Your program didn't contain the line that is in error, it appears to be from a different file.
– Ron Dunn
Nov 24 '18 at 0:44
First question comment: It is great that you've provided an example of the problem, and in future it would be more useful if the example just focussed on the error, not the whole program. Your program didn't contain the line that is in error, it appears to be from a different file.
– Ron Dunn
Nov 24 '18 at 0:44
add a comment |
1 Answer
1
active
oldest
votes
I have found my mistake.
The problem is in the "error->message" (GError) that gets set by the "g_key_file_load_from_file()" function in my error check routine.
if(!g_key_file_load_from_file(key_file, cfgFile, G_KEY_FILE_NONE, &error))
{
printf("ERROR MESSAGE %sn", error->message);
g_debug("%s", error->message);
g_key_file_free (key_file);
return 1;
}
Thus if there is an error in the conf file or conf file does not exist then "g_key_file_load_from_file" returns 1 and gracefully exits the function. I failed to realize that if an error occurs anywhere in the conf file it will also be flagged here.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53453713%2fgtk-error-message-key-file-contains-line-which-is-not-a-key-value-pair-group-o%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I have found my mistake.
The problem is in the "error->message" (GError) that gets set by the "g_key_file_load_from_file()" function in my error check routine.
if(!g_key_file_load_from_file(key_file, cfgFile, G_KEY_FILE_NONE, &error))
{
printf("ERROR MESSAGE %sn", error->message);
g_debug("%s", error->message);
g_key_file_free (key_file);
return 1;
}
Thus if there is an error in the conf file or conf file does not exist then "g_key_file_load_from_file" returns 1 and gracefully exits the function. I failed to realize that if an error occurs anywhere in the conf file it will also be flagged here.
add a comment |
I have found my mistake.
The problem is in the "error->message" (GError) that gets set by the "g_key_file_load_from_file()" function in my error check routine.
if(!g_key_file_load_from_file(key_file, cfgFile, G_KEY_FILE_NONE, &error))
{
printf("ERROR MESSAGE %sn", error->message);
g_debug("%s", error->message);
g_key_file_free (key_file);
return 1;
}
Thus if there is an error in the conf file or conf file does not exist then "g_key_file_load_from_file" returns 1 and gracefully exits the function. I failed to realize that if an error occurs anywhere in the conf file it will also be flagged here.
add a comment |
I have found my mistake.
The problem is in the "error->message" (GError) that gets set by the "g_key_file_load_from_file()" function in my error check routine.
if(!g_key_file_load_from_file(key_file, cfgFile, G_KEY_FILE_NONE, &error))
{
printf("ERROR MESSAGE %sn", error->message);
g_debug("%s", error->message);
g_key_file_free (key_file);
return 1;
}
Thus if there is an error in the conf file or conf file does not exist then "g_key_file_load_from_file" returns 1 and gracefully exits the function. I failed to realize that if an error occurs anywhere in the conf file it will also be flagged here.
I have found my mistake.
The problem is in the "error->message" (GError) that gets set by the "g_key_file_load_from_file()" function in my error check routine.
if(!g_key_file_load_from_file(key_file, cfgFile, G_KEY_FILE_NONE, &error))
{
printf("ERROR MESSAGE %sn", error->message);
g_debug("%s", error->message);
g_key_file_free (key_file);
return 1;
}
Thus if there is an error in the conf file or conf file does not exist then "g_key_file_load_from_file" returns 1 and gracefully exits the function. I failed to realize that if an error occurs anywhere in the conf file it will also be flagged here.
answered Nov 24 '18 at 18:48
maihoaomvmaihoaomv
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53453713%2fgtk-error-message-key-file-contains-line-which-is-not-a-key-value-pair-group-o%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
First question comment: It is great that you've provided an example of the problem, and in future it would be more useful if the example just focussed on the error, not the whole program. Your program didn't contain the line that is in error, it appears to be from a different file.
– Ron Dunn
Nov 24 '18 at 0:44