From c1a639115be164e1c854141e88a4cba94febf14d Mon Sep 17 00:00:00 2001 From: mishas Date: Tue, 13 Mar 2007 06:04:41 +0000 Subject: [PATCH] put stubs for loading/saving configuration git-svn-id: file:///svnroot/simple-launcher/trunk@72 3ba93dab-e023-0410-b42a-de7732cf370a --- simple-launcher.cc | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/simple-launcher.cc b/simple-launcher.cc index 41895a6..672897d 100644 --- a/simple-launcher.cc +++ b/simple-launcher.cc @@ -17,6 +17,7 @@ #include #include +#include #include @@ -48,6 +49,9 @@ public: GtkWidget *getWidget() { return myWidget; } private: + void loadConfig(); + void saveConfig(); + bool initWidget(); void buttonClicked(GtkToolButton *); @@ -63,7 +67,7 @@ private: LauncherItems myItems; - static char *ourFiles[]; + static char *ourDirs[]; }; // Hildon home applet interface functions @@ -107,13 +111,8 @@ int hildon_home_applet_lib_save_state (void *applet_data, void **state_data, int // SimpleLauncherApplet implementation -char *SimpleLauncherApplet::ourFiles[] = { - "/usr/share/applications/hildon/FBReader.desktop", - "/usr/share/applications/hildon/mp_ui.desktop", - "/usr/share/applications/hildon/osso-xterm.desktop", - "/usr/share/applications/hildon/filemanager.desktop", - "/usr/share/applications/hildon/osso-application-installer.desktop", - "/usr/share/applications/hildon/hildon-control-panel.desktop", +char *SimpleLauncherApplet::ourDirs[] = { + "/usr/share/applications/hildon", NULL }; @@ -126,15 +125,7 @@ bool SimpleLauncherApplet::doInit(void *state_data, int *state_size) { return false; } - for (int i = 0 ; ourFiles[i] != NULL ; ++i) { - LaunchableItem *item = new LaunchableItem(); - - if (item->load(ourFiles[i])) { - myItems.push_back(std::pair(ourFiles[i], item)); - } else { - delete item; - } - } + loadConfig(); if (!initWidget()) { return false; @@ -166,6 +157,33 @@ SimpleLauncherApplet::~SimpleLauncherApplet() { } } +static char *configFileName="/home/user/.slarc"; + +void SimpleLauncherApplet::loadConfig() { +#if 0 + for (int i = 0 ; ourFiles[i] != NULL ; ++i) { + LaunchableItem *item = new LaunchableItem(); + + if (item->load(ourFiles[i])) { + myItems.push_back(std::pair(ourFiles[i], item)); + } else { + delete item; + } + } +#endif +} + +void SimpleLauncherApplet::saveConfig() { + // TODO: make saving config an atomic operation + std::ofstream config(configFileName); + + if (config) { + for (LauncherItems::const_iterator it = myItems.begin(); it != myItems.end(); ++it) { + config << it->first << ',' << it->second->isEnabled() << std::endl; + } + } +} + bool SimpleLauncherApplet::initWidget() { int button_no = 0; -- 1.7.9.5