From 515b45636a232da39e9cd9bbe1f451819b849b8f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 15 May 2015 10:00:38 +0200 Subject: Start using C++-11. --- plugingui/plugingui.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugingui') diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index 5408334..60a75fc 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -311,7 +311,7 @@ void PluginGUI::init() (void*)&closing); window->setFixedSize(370, 330); - window->setCaption("DrumGizmo v"VERSION); + window->setCaption("DrumGizmo v" VERSION); GUI::Label *lbl_title = new GUI::Label(window); lbl_title->setText("DrumGizmo"); @@ -437,7 +437,7 @@ void PluginGUI::init() l2->resize(window->width() - 40, 2); GUI::Label *lbl_version = new GUI::Label(window); - lbl_version->setText(".::. v"VERSION" .::. http://www.drumgizmo.org .::. GPLv3 .::."); + lbl_version->setText(".::. v" VERSION " .::. http://www.drumgizmo.org .::. GPLv3 .::."); lbl_version->move(16, 300); lbl_version->resize(window->width(), 20); /* -- cgit v1.2.3 From 6a19e8f182183ad88df91d4a46e418fb4d42f9bd Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 15 May 2015 10:24:10 +0200 Subject: Make sure that M_PI is defined. --- plugingui/knob.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'plugingui') diff --git a/plugingui/knob.cc b/plugingui/knob.cc index ca861b5..4cac180 100644 --- a/plugingui/knob.cc +++ b/plugingui/knob.cc @@ -30,6 +30,11 @@ #include #include + +// M_PI is not defined in math.h if __STRICT_ANSI__ is defined. +#ifdef __STRICT_ANSI__ +#undef __STRICT_ANSI__ +#endif #include GUI::Knob::Knob(Widget *parent) -- cgit v1.2.3 From 9555c6e2734977c82023907f82a3ae82f845720a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 15 May 2015 11:53:17 +0200 Subject: New ConfigFile class for generic config file reading/writing in homedir .drumgizmo folder. Use said new class for PluginConfig class. --- plugingui/Makefile.am | 1 + plugingui/pluginconfig.cc | 122 +++------------------------------------------- plugingui/pluginconfig.h | 22 ++++----- 3 files changed, 18 insertions(+), 127 deletions(-) (limited to 'plugingui') diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index bdb11cb..00b0881 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -14,6 +14,7 @@ plugingui_CFLAGS = $(plugingui_CXXFLAGS) plugingui_SOURCES = \ $(PLUGIN_GUI_SOURCES) \ + $(top_srcdir)/src/configfile.cc \ $(top_srcdir)/src/thread.cc \ $(top_srcdir)/src/semaphore.cc \ $(top_srcdir)/src/mutex.cc \ diff --git a/plugingui/pluginconfig.cc b/plugingui/pluginconfig.cc index d57d9df..0beef6e 100644 --- a/plugingui/pluginconfig.cc +++ b/plugingui/pluginconfig.cc @@ -26,140 +26,34 @@ */ #include "pluginconfig.h" -#include -#include -#include -#include - -#include "directory.h" - -#ifdef WIN32 -#include -#include -#include -#include -#else -#endif - #include #define CONFIGFILENAME "plugingui.conf" -#ifdef WIN32 - #define SEP "\\" - #define CONFIGDIRNAME ".drumgizmo" -#else - #define SEP "/" - #define CONFIGDIRNAME ".drumgizmo" -#endif - Config::Config() + : ConfigFile(CONFIGFILENAME) { - } Config::~Config() { - -} - -static std::string configPath() { - #ifdef WIN32 - std::string configpath; - TCHAR szPath[256]; - if(SUCCEEDED(SHGetFolderPath(NULL, - CSIDL_APPDATA | CSIDL_FLAG_CREATE, - NULL, - 0, - szPath))); { - configpath = szPath; - } -#else - std::string configpath = strdup(getenv("HOME")); -#endif - configpath += SEP; - configpath += CONFIGDIRNAME; - - return configpath; -} - -static bool createConfigPath() { - std::string configpath = configPath(); - - if(!Directory::exists(configpath)) { - DEBUG(pluginconfig, "No configuration exists, creating directory '%s'\n", configpath.c_str()); -#ifdef WIN32 - if( (mkdir(configpath.c_str())) < 0) { -#else - if( (mkdir(configpath.c_str(), 0755)) < 0) { -#endif - DEBUG(pluginconfig, "Could not create config directory\n"); - } - return false; - } - - return true; -} - -static FILE* openConfigFile(std::string mode) { - - std::string configpath = configPath(); - - FILE *fp; - std::string configfile = configpath; - configfile += SEP; - configfile += CONFIGFILENAME; - - DEBUG(pluginconfig, "Opening config file '%s'\n", configfile.c_str()); - if(! (fp = fopen(configfile.c_str(), mode.c_str())) ) { - return NULL; - } - - return fp; } void Config::load() { - DEBUG(pluginconfig, "Loading config file...\n"); - FILE *fp = openConfigFile("r"); - if(!fp) return; - lastkit.clear(); lastmidimap.clear(); - char buf[4096]; - while( fgets(buf, 4096, fp) ) { - if(!strncmp(buf, "lastkit:", 8)) { - DEBUG(pluginconfig, "Loading last kit path\n"); - // Dont copy newline - if(strlen(buf) > 8 + 1) { - lastkit.append(buf+8, strlen(buf+8) - 1); - DEBUG(pluginconfig, "\t path is %s\n", lastkit.c_str()); - } - } - if(!strncmp(buf, "lastmidimap:", 12)) { - DEBUG(pluginconfig, "Loading lastmidimap path\n"); - // Dont copy newline - if(strlen(buf) > 12+1) lastmidimap.append(buf+12, strlen(buf+12) - 1); - DEBUG(pluginconfig, "\t path is %s\n", lastmidimap.c_str()); - } - } + ConfigFile::load(); + + lastkit = getValue("lastkit"); + lastmidimap = getValue("lastmidimap"); } void Config::save() { - DEBUG(pluginconfig, "Saving configuration...\n"); - - createConfigPath(); - - FILE *fp = openConfigFile("w"); - if(!fp) return; - - std::string buf; - buf.append("lastkit:" + lastkit + '\n'); - buf.append("lastmidimap:" + lastmidimap + '\n'); - - fputs(buf.c_str(), fp); + setValue("lastkit", lastkit); + setValue("lastmidimap", lastmidimap); - fclose(fp); + ConfigFile::save(); } diff --git a/plugingui/pluginconfig.h b/plugingui/pluginconfig.h index d0e9bcd..29d2ef5 100644 --- a/plugingui/pluginconfig.h +++ b/plugingui/pluginconfig.h @@ -27,22 +27,18 @@ #ifndef __DRUMGIZMO_CONFIG_H__ #define __DRUMGIZMO_CONFIG_H__ -#include -#include +#include -#define DIRECTORY_HIDDEN 1 +class Config : public ConfigFile { +public: + Config(); + ~Config(); -class Config { + void load(); + void save(); - public: - Config(); - ~Config(); - - void load(); - void save(); - - std::string lastkit; - std::string lastmidimap; + std::string lastkit; + std::string lastmidimap; }; #endif/*__DRUMGIZMO_CONFIG_H__*/ -- cgit v1.2.3 From ceda77eb38f0b0824f03348f5291e3a42d8f7306 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 15 May 2015 17:36:41 +0200 Subject: Add support for referenced files through refs.conf. --- plugingui/filebrowser.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'plugingui') diff --git a/plugingui/filebrowser.cc b/plugingui/filebrowser.cc index 6ecbc09..f025c25 100644 --- a/plugingui/filebrowser.cc +++ b/plugingui/filebrowser.cc @@ -160,6 +160,15 @@ static void handleKeyEvent(void *ptr) { lb->clearSelectedValue(); GUI::LineEdit *le = prv->lineedit; + std::string value = le->text(); + if(value.size() > 1 && value[0] == '@') { + DEBUG(filebrowser, "Selecting ref-file '%s'\n", value.c_str()); + if(prv->filesel_handler) { + prv->filesel_handler(prv->ptr, value); + } + return; + } + prv->dir->setPath(le->text()); changeDir(ptr); } -- cgit v1.2.3