#include "acidlaunch.h"
time_t last_config_read_mtime=0;
/* re-read config file every few seconds */
gint reread_config(gpointer data)
{
LauncherWindow* window = (LauncherWindow*)data;
AcidLaunchNode* config;
struct stat filestat;
char* filename = prefsFileName("config.xml");
/* get the last modified date of the config file */
stat(filename, &filestat);
/* re-read the config file if it's been modified */
if(filestat.st_mtime > last_config_read_mtime)
{
if(config = readConfig("config.xml"))
{
list<ConfigNode*>::const_iterator iter;
/* just do the first launcher for now */
iter=config->children().begin();
window->setPrefs((LauncherNode*)(*iter));
window->show();
}
last_config_read_mtime = filestat.st_mtime;
delete config;
}
delete[] filename;
}
int main(int argc, char **argv)
{
AcidLaunchNode* config;
LauncherWindow* window;
gtk_init (&argc, &argv);
gdk_rgb_init ();
if(!createInitialConfig())
{
cerr << "Error initialising your configuration\n";
exit(10);
}
if(config = readConfig("config.xml"))
{
list<ConfigNode*>::const_iterator iter;
/* just do the first launcher for now */
iter=config->children().begin();
window = new LauncherWindow();
window->setPrefs((LauncherNode*)(*iter));
window->show();
gtk_timeout_add(5000, reread_config, window);
delete config;
last_config_read_mtime = time(NULL);
}
gtk_main();
}
syntax highlighted by Code2HTML, v. 0.9.1