[SCM] calf/master: More work on config support, still not hooked up in the code.

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 7699584d301643616cfdb33a45577bd711fd936a
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Fri Sep 10 23:21:02 2010 +0100

    More work on config support, still not hooked up in the code.

diff --git a/Makefile.am b/Makefile.am
index 7d84a9f..5e13d04 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,10 +7,17 @@ distdir = $(PACKAGE)-$(VERSION)
 desktopfilesdir = $(datadir)/applications
 dist_desktopfiles_DATA = calf.desktop
 
-EXTRA_DIST = COPYING.GPL TODO autogen.sh calf.glade presets.xml calf.7 calfjackhost.1
+EXTRA_DIST = COPYING.GPL TODO autogen.sh calf.glade presets.xml calf.7 calfjackhost.1 calf.schema
 
 dist_man_MANS = calf.7 calfjackhost.1
 
 clean-local:
 	rm -f *~ *.old *.bak
 	rm -rf autom4te.cache
+
+install-data-local:
+	GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_srcdir)/calf.schemas
+        
+uninstall-local:
+	GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-uninstall-rule $(top_srcdir)/calf.schemas
+        
diff --git a/calf.schemas b/calf.schemas
new file mode 100644
index 0000000..7a34e64
--- /dev/null
+++ b/calf.schemas
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<gconfschemafile>
+  <schemalist>
+    <schema>
+      <key>/schemas/apps/calf/show-rack-ears</key>
+      <applyto>/apps/calf/show-rack-ears</applyto>
+      <owner>calf</owner>
+      <type>bool</type>
+      <locale name="C">
+        <default>true</default>
+        <short>Show rack ear graphic.</short>
+        <long>Whether or not to show the rack ears graphics.</long>
+      </locale>
+    </schema>
+  </schemalist>
+</gconfschemafile>
diff --git a/configure.ac b/configure.ac
index 4599f29..8df2a3f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -159,6 +159,11 @@ AC_ARG_ENABLE(debug,
   [set_enable_debug="no"])
 AC_MSG_RESULT($set_enable_debug)
 
+if test "$GUI_ENABLED" = "yes" -a "$JACK_FOUND" = "yes"; then
+  AC_PATH_PROG(GCONFTOOL, gconftool-2)
+  AM_GCONF_SOURCE_2
+fi
+
 ############################################################################################
 # Compute status shell variables
 
diff --git a/src/calf/gui_config.h b/src/calf/gui_config.h
index 36d7291..a923376 100644
--- a/src/calf/gui_config.h
+++ b/src/calf/gui_config.h
@@ -6,9 +6,18 @@
 #include <gconf/gconf-client.h>
 #include <string>
 
+struct config_exception: public std::exception
+{
+    std::string content;
+    const char *content_ptr;
+    config_exception(const std::string &text) : content(text) { content_ptr = content.c_str(); }
+    virtual const char *what() const throw() { return content_ptr; }
+    virtual ~config_exception() throw() { }
+};
+
 struct gui_config_db_iface
 {
-    virtual bool has_key(const char *key) = 0;
+    virtual bool has_dir(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;
@@ -26,7 +35,7 @@ protected:
     void handle_error(GError *error);
 public:
     gconf_config_db(const char *parent_key);
-    virtual bool has_key(const char *key);
+    virtual bool has_dir(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);
diff --git a/src/gui_config.cpp b/src/gui_config.cpp
index 49ea58e..667c24c 100644
--- a/src/gui_config.cpp
+++ b/src/gui_config.cpp
@@ -15,16 +15,16 @@ 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);
+    rows = db->get_int("rack-rows", gui_config().rows);
+    cols = db->get_int("rack-cols", gui_config().cols);
+    rack_ears = db->get_bool("show-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);
+    db->set_int("rack-rows", rows);
+    db->set_int("rack-cols", cols);
+    db->set_bool("show-rack-ears", rack_ears);
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -33,20 +33,35 @@ gconf_config_db::gconf_config_db(const char *parent_key)
 {
     prefix = string(parent_key) + "/";
     client = gconf_client_get_default();
+    if (client)
+    {
+        GError *err = NULL;
+        gconf_client_add_dir(client, parent_key, GCONF_CLIENT_PRELOAD_ONELEVEL, &err);
+        if (err)
+        {
+            client = NULL;
+            handle_error(err);
+        }
+    }
 }
 
 void gconf_config_db::handle_error(GError *error)
 {
     if (error)
     {
+        string msg = error->message;
         g_error_free(error);
+        throw config_exception(msg.c_str());
     }
 }
 
-bool gconf_config_db::has_key(const char *key)
+bool gconf_config_db::has_dir(const char *key)
 {
-    g_warning("Not implemented: has_key");
-    return true;
+    GError *err = NULL;
+    bool result = gconf_client_dir_exists(client, (prefix + key).c_str(), &err);
+    if (err)
+        handle_error(err);
+    return result;
 }
 
 bool gconf_config_db::get_bool(const char *key, bool def_value)

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list