[SCM] calf/master: Initial, highly incomplete implementation of configuration database (using GConf).

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:40:20 UTC 2013


The following commit has been merged in the master branch:
commit 18e13057cadacdaaaf05358bada0468572c28385
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Thu Sep 2 19:56:24 2010 +0100

    Initial, highly incomplete implementation of configuration database (using GConf).

diff --git a/configure.ac b/configure.ac
index c19ca19..4599f29 100644
--- a/configure.ac
+++ b/configure.ac
@@ -98,9 +98,9 @@ LV2_ENABLED=$LV2_FOUND
 LASH_ENABLED=$LASH_FOUND
 
 if test "$JACK_FOUND" = "yes" -o "$DSSI_FOUND" = "yes" -o "$LV2_FOUND" = "yes"; then
-  PKG_CHECK_MODULES(GUI_DEPS, gtk+-2.0 >= 2.8.0 libglade-2.0 >= 2.4.0 cairo >= 1.2.0,
+  PKG_CHECK_MODULES(GUI_DEPS, gtk+-2.0 >= 2.8.0 gconf-2.0 >= 2.8.0 libglade-2.0 >= 2.4.0 cairo >= 1.2.0,
     GUI_ENABLED="yes",
-    GUI_ENABLED="no (GTK+ 2.8, cairo 1.2 and libglade 2.4.0 or newer required)"
+    GUI_ENABLED="no (GTK+ 2.8, GConf 2.8, cairo 1.2 and libglade 2.4.0 or newer required)"
   )
 fi
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 602f262..e42dc51 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -64,7 +64,7 @@ if USE_LV2_GTK_GUI
 
 # Version WITH out-of-process GUI - links GTK+, UI controls etc.
 
-calflv2gui_la_SOURCES = gui.cpp gui_controls.cpp ctl_curve.cpp ctl_keyboard.cpp ctl_led.cpp custom_ctl.cpp metadata.cpp giface.cpp preset.cpp preset_gui.cpp lv2gui.cpp osctl.cpp osctlnet.cpp utils.cpp
+calflv2gui_la_SOURCES = gui.cpp gui_config.cpp gui_controls.cpp ctl_curve.cpp ctl_keyboard.cpp ctl_led.cpp custom_ctl.cpp metadata.cpp giface.cpp preset.cpp preset_gui.cpp lv2gui.cpp osctl.cpp osctlnet.cpp utils.cpp
 
 if USE_DEBUG
 calflv2gui_la_LDFLAGS = -rpath $(lv2dir) -avoid-version -module -lexpat $(GUI_DEPS_LIBS) -disable-static
@@ -90,7 +90,7 @@ endif
 endif
 
 if USE_GUI
-libcalfgui_la_SOURCES = gui.cpp gui_controls.cpp ctl_curve.cpp ctl_keyboard.cpp ctl_led.cpp preset_gui.cpp custom_ctl.cpp osctl.cpp osctlnet.cpp osctl_glib.cpp utils.cpp
+libcalfgui_la_SOURCES = gui.cpp gui_config.cpp gui_controls.cpp ctl_curve.cpp ctl_keyboard.cpp ctl_led.cpp preset_gui.cpp custom_ctl.cpp osctl.cpp osctlnet.cpp osctl_glib.cpp utils.cpp
 libcalfgui_la_LDFLAGS = -static -disable-shared
 endif
 
diff --git a/src/calf/Makefile.am b/src/calf/Makefile.am
index 5430340..0fbc3fa 100644
--- a/src/calf/Makefile.am
+++ b/src/calf/Makefile.am
@@ -1,6 +1,6 @@
 noinst_HEADERS = audio_fx.h benchmark.h biquad.h buffer.h custom_ctl.h \
     ctl_curve.h ctl_keyboard.h ctl_led.h \
-    delay.h envelope.h fft.h fixed_point.h giface.h gui.h gui_controls.h inertia.h jackhost.h \
+    delay.h envelope.h fft.h fixed_point.h giface.h gui.h gui_config.h gui_controls.h inertia.h jackhost.h \
     host_session.h ladspa_wrap.h loudness.h \
     lv2_contexts.h lv2_data_access.h lv2_event.h lv2_external_ui.h \
     lv2_progress.h lv2_polymorphic_port.h lv2_string_port.h lv2_ui.h \
diff --git a/src/calf/gui_config.h b/src/calf/gui_config.h
new file mode 100644
index 0000000..36d7291
--- /dev/null
+++ b/src/calf/gui_config.h
@@ -0,0 +1,51 @@
+#ifndef CALF_GUI_CONFIG_H
+#define CALF_GUI_CONFIG_H
+
+#include <gtk/gtk.h>
+#include <glib.h>
+#include <gconf/gconf-client.h>
+#include <string>
+
+struct gui_config_db_iface
+{
+    virtual bool has_key(const char *key) = 0;
+    virtual bool get_bool(const char *key, bool def_value) = 0;
+    virtual int get_int(const char *key, int def_value) = 0;
+    virtual std::string get_string(const char *key, const std::string &def_value) = 0;
+    virtual void set_bool(const char *key, bool value) = 0;
+    virtual void set_int(const char *key, int value) = 0;
+    virtual void set_string(const char *key, const std::string &value) = 0;
+    virtual ~gui_config_db_iface() {}
+};
+
+class gconf_config_db: public gui_config_db_iface
+{
+protected:
+    GConfClient *client;
+    std::string prefix;
+    void handle_error(GError *error);
+public:
+    gconf_config_db(const char *parent_key);
+    virtual bool has_key(const char *key);
+    virtual bool get_bool(const char *key, bool def_value);
+    virtual int get_int(const char *key, int def_value);
+    virtual std::string get_string(const char *key, const std::string &def_value);
+    virtual void set_bool(const char *key, bool value);
+    virtual void set_int(const char *key, int value);
+    virtual void set_string(const char *key, const std::string &value);
+    virtual ~gconf_config_db();
+    
+};
+
+struct gui_config
+{
+    int cols, rows;
+    bool rack_ears;
+    
+    gui_config();
+    ~gui_config();
+    void load(gui_config_db_iface *db);
+    void save(gui_config_db_iface *db);
+};
+
+#endif
diff --git a/src/gui_config.cpp b/src/gui_config.cpp
new file mode 100644
index 0000000..49ea58e
--- /dev/null
+++ b/src/gui_config.cpp
@@ -0,0 +1,109 @@
+#include <calf/gui_config.h>
+
+using namespace std;
+
+gui_config::gui_config()
+{
+    rows = 0;
+    cols = 1;
+    rack_ears = true;
+}
+
+gui_config::~gui_config()
+{
+}
+
+void gui_config::load(gui_config_db_iface *db)
+{
+    rows = db->get_int("rows", gui_config().rows);
+    cols = db->get_int("cols", gui_config().cols);
+    rack_ears = db->get_bool("rack-ears", gui_config().rack_ears);
+}
+
+void gui_config::save(gui_config_db_iface *db)
+{
+    db->set_int("rows", rows);
+    db->set_int("cols", cols);
+    db->set_bool("rack-ears", rack_ears);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+gconf_config_db::gconf_config_db(const char *parent_key)
+{
+    prefix = string(parent_key) + "/";
+    client = gconf_client_get_default();
+}
+
+void gconf_config_db::handle_error(GError *error)
+{
+    if (error)
+    {
+        g_error_free(error);
+    }
+}
+
+bool gconf_config_db::has_key(const char *key)
+{
+    g_warning("Not implemented: has_key");
+    return true;
+}
+
+bool gconf_config_db::get_bool(const char *key, bool def_value)
+{
+    GError *err = NULL;
+    bool value = (bool)gconf_client_get_bool(client, (prefix + key).c_str(), &err);
+    if (err)
+        handle_error(err);
+    return value;
+}
+
+int gconf_config_db::get_int(const char *key, int def_value)
+{
+    GError *err = NULL;
+    int value = gconf_client_get_int(client, (prefix + key).c_str(), &err);
+    if (err)
+        handle_error(err);
+    return value;
+}
+
+std::string gconf_config_db::get_string(const char *key, const std::string &def_value)
+{
+    GError *err = NULL;
+    gchar *value = (gchar *)gconf_client_get_string(client, (prefix + key).c_str(), &err);
+    if (err)
+        handle_error(err);
+    string svalue = value;
+    g_free(value);
+    return svalue;
+}
+
+void gconf_config_db::set_bool(const char *key, bool value)
+{
+    GError *err = NULL;
+    gconf_client_set_bool(client, (prefix + key).c_str(), (gboolean)value, &err);
+    if (err)
+        handle_error(err);
+}
+
+void gconf_config_db::set_int(const char *key, int value)
+{
+    GError *err = NULL;
+    gconf_client_set_int(client, (prefix + key).c_str(), value, &err);
+    if (err)
+        handle_error(err);
+}
+
+void gconf_config_db::set_string(const char *key, const std::string &value)
+{
+    GError *err = NULL;
+    gconf_client_set_string(client, (prefix + key).c_str(), value.c_str(), &err);
+    if (err)
+        handle_error(err);
+}
+
+gconf_config_db::~gconf_config_db()
+{
+    g_object_unref(G_OBJECT(client));
+}
+

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list