X-Git-Url: http://git.maemo.org/git/?p=simple-launcher;a=blobdiff_plain;f=simple-launcher.cc;h=3ebd1da1abf386b1c038cb31be76af971c59e80d;hp=92657a87fb9d6c1230fe0e937ad3a2e71f30b1a9;hb=b843813af2067326837dcebbee364b1efcd56518;hpb=7af246bfd264a70dc975df685928425370585d17 diff --git a/simple-launcher.cc b/simple-launcher.cc index 92657a8..3ebd1da 100644 --- a/simple-launcher.cc +++ b/simple-launcher.cc @@ -23,7 +23,6 @@ #include -#include #include #include "launcher-item.h" @@ -36,6 +35,21 @@ #define SL_APPLET_GCONF_PATH "/apps/simple-launcher" +// A copy of interface functions from hildon-home-plugin-interface (new hildon desktop does not have it) {{{ + +extern "C" { + + void *hildon_home_applet_lib_initialize(void *state_data, int *state_size, GtkWidget **widget); + int hildon_home_applet_lib_save_state(void *applet_data, void **state_data, int *state_size); + void hildon_home_applet_lib_background(void *applet_data); + void hildon_home_applet_lib_foreground(void *applet_data); + void hildon_home_applet_lib_deinitialize(void *applet_data); + GtkWidget *hildon_home_applet_lib_settings(void *applet_data, GtkWindow *parent); + +}; + +// }}} + class SimpleLauncherApplet { public: SimpleLauncherApplet(const GConfKey&); @@ -135,7 +149,7 @@ char *SimpleLauncherApplet::ourDirs[] = { }; // SimpleLauncherApplet::SimpleLauncherApplet() : myMainSettings(myClient.getKey(SL_APPLET_GCONF_PATH)), myContext(NULL), myWidget(NULL), myParent(NULL) { -SimpleLauncherApplet::SimpleLauncherApplet(const GConfKey& base) : myContext(NULL), myWidget(NULL), myParent(NULL), myTransparent(base, "transparent", true), myIconSize(base, "icon_size", 48) { +SimpleLauncherApplet::SimpleLauncherApplet(const GConfKey& base) : myContext(NULL), myWidget(NULL), myParent(NULL), myTransparent(base, "transparent", false), myIconSize(base, "icon_size", 48) { } bool SimpleLauncherApplet::doInit(void *state_data, int *state_size) { @@ -155,12 +169,13 @@ bool SimpleLauncherApplet::doInit(void *state_data, int *state_size) { SimpleLauncherApplet::~SimpleLauncherApplet() { myItems.clear(); - +#if 0 + // This does not seem to be necessary if (myWidget != NULL) { gtk_widget_destroy(myWidget); myWidget = NULL; } - +#endif if (myContext != NULL) { osso_deinitialize(myContext); myContext = NULL; @@ -183,11 +198,19 @@ void SimpleLauncherApplet::addItem(LauncherItems& items, const std::string& name } } -// FIXME: this probably should be done somehow differently -static char *configFileName="/home/user/.slarc"; +// {{{ Configuration file managment +static const gchar *getConfigFileName() { + static gchar *configFileName = NULL; + + if (configFileName == NULL) { + configFileName = g_build_filename(g_get_home_dir(), ".slarc", NULL); + } + + return configFileName; +} void SimpleLauncherApplet::loadConfig() { - std::ifstream config(configFileName); + std::ifstream config(getConfigFileName()); if (config) { char *buffer = new char [1024]; @@ -202,13 +225,13 @@ void SimpleLauncherApplet::loadConfig() { addItem(myItems, buffer, (p != NULL && (*p == '1' || *p == 'y' || *p == 'Y'))); } - delete buffer; + delete [] buffer; } } void SimpleLauncherApplet::saveConfig() { // TODO: make saving config an atomic operation - std::ofstream config(configFileName); + std::ofstream config(getConfigFileName()); if (config) { for (size_t i = 0 ; i < myItems.size() ; ++i) { @@ -217,6 +240,8 @@ void SimpleLauncherApplet::saveConfig() { } } +// }}} + void SimpleLauncherApplet::updateItems(LauncherItems& items) { for (int i = 0 ; ourDirs[i] != NULL ; ++i) { processDirectory(items, ourDirs[i]); @@ -370,7 +395,7 @@ void SimpleLauncherApplet::runDialog() { ; // FIXME: do I want to do anything in here? } - newItems.clear(); + // newItems.clear(); // TODO: do I really need it? } // vim:ts=2:sw=2:et