[SCM] calf/master: Nuke GConf from the orbit. It's the only way to be sure.
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:40:46 UTC 2013
The following commit has been merged in the master branch:
commit ae8e15831fade7c02f2cd0f8db0343e0e3064391
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Sat Dec 17 13:13:31 2011 +0000
Nuke GConf from the orbit. It's the only way to be sure.
diff --git a/Makefile.am b/Makefile.am
index caf4475..04124ae 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,7 +7,7 @@ distdir = $(PACKAGE)-$(VERSION)
desktopfilesdir = $(datadir)/applications
dist_desktopfiles_DATA = calf.desktop
-EXTRA_DIST = COPYING.GPL TODO autogen.sh presets.xml calf.7 calfjackhost.1 calf-gui.xml calf.schemas
+EXTRA_DIST = COPYING.GPL TODO autogen.sh presets.xml calf.7 calfjackhost.1 calf-gui.xml
dist_man_MANS = calf.7 calfjackhost.1
@@ -16,15 +16,5 @@ clean-local:
rm -rf autom4te.cache
install-data-local:
-if USE_JACK
-if USE_GUI
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_srcdir)/calf.schemas
-endif
-endif
uninstall-local:
-if USE_JACK
-if USE_GUI
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-uninstall-rule $(top_srcdir)/calf.schemas
-endif
-endif
diff --git a/calf.schemas b/calf.schemas
deleted file mode 100644
index 7a34e64..0000000
--- a/calf.schemas
+++ /dev/null
@@ -1,16 +0,0 @@
-<?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 de1b6ef..5e62ba4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -88,9 +88,9 @@ LV2_ENABLED=$LV2_FOUND
LASH_ENABLED=$LASH_FOUND
if test "$JACK_FOUND" = "yes" -o "$LV2_FOUND" = "yes"; then
- PKG_CHECK_MODULES(GUI_DEPS, gtk+-2.0 >= 2.12.0 gconf-2.0 >= 2.8.0 cairo >= 1.2.0,
+ PKG_CHECK_MODULES(GUI_DEPS, gtk+-2.0 >= 2.12.0 cairo >= 1.2.0,
GUI_ENABLED="yes",
- GUI_ENABLED="no (GTK+ 2.12, GConf 2.8 and cairo 1.2 or newer required)"
+ GUI_ENABLED="no (GTK+ 2.12 and cairo 1.2 or newer required)"
)
fi
@@ -126,16 +126,6 @@ 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, no)
- if test "$GCONFTOOL" = "no"; then
- AC_MSG_ERROR([gconftool-2 not found - do you have GConf devel package installed?])
- fi
- AM_GCONF_SOURCE_2
-else
- AM_CONDITIONAL(GCONF_SCHEMAS_INSTALL, false)
-fi
-
############################################################################################
# Compute status shell variables
diff --git a/src/calf/gui.h b/src/calf/gui.h
index a01f039..d1075ca 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -173,6 +173,7 @@ struct session_environment_iface
class gui_environment: public gui_environment_iface
{
private:
+ GKeyFile *keyfile;
calf_utils::config_db_iface *config_db;
calf_utils::gui_config gui_config;
diff --git a/src/calf/gui_config.h b/src/calf/gui_config.h
index 4e1c171..88f9c92 100644
--- a/src/calf/gui_config.h
+++ b/src/calf/gui_config.h
@@ -2,8 +2,8 @@
#define CALF_GUI_CONFIG_H
#include <glib.h>
-#include <gconf/gconf-client.h>
#include <string>
+#include <vector>
namespace calf_utils {
@@ -36,18 +36,34 @@ struct config_db_iface
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 void save() = 0;
virtual config_notifier_iface *add_listener(config_listener_iface *listener) = 0;
virtual ~config_db_iface() {}
};
-class gconf_config_db: public config_db_iface
+class gkeyfile_config_db: public config_db_iface
{
protected:
- GConfClient *client;
- std::string prefix;
+ class notifier: public config_notifier_iface
+ {
+ protected:
+ gkeyfile_config_db *parent;
+ config_listener_iface *listener;
+ notifier(gkeyfile_config_db *_parent, config_listener_iface *_listener);
+ virtual ~notifier();
+ friend class gkeyfile_config_db;
+ };
+protected:
+ GKeyFile *keyfile;
+ std::string filename;
+ std::string section;
+ std::vector<notifier *> notifiers;
+
void handle_error(GError *error);
+ void remove_notifier(notifier *n);
+ friend class notifier;
public:
- gconf_config_db(const char *parent_key);
+ gkeyfile_config_db(GKeyFile *kf, const char *filename, const char *section);
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);
@@ -55,8 +71,9 @@ public:
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 void save();
virtual config_notifier_iface *add_listener(config_listener_iface *listener);
- virtual ~gconf_config_db();
+ virtual ~gkeyfile_config_db();
};
struct gui_config
diff --git a/src/gui.cpp b/src/gui.cpp
index f540f56..ec98f31 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -483,7 +483,7 @@ void tips_tricks_action(GtkAction *action, plugin_gui_window *gui_win)
"If you consider those a waste of screen space, you can turn them off in Preferences dialog in Calf JACK host. The setting affects all versions of the GUI (DSSI, LV2 GTK+, LV2 External, JACK host).\n"
"\n"
;
- GtkMessageDialog *dlg = GTK_MESSAGE_DIALOG(gtk_message_dialog_new(gui_win->toplevel, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_OTHER, GTK_BUTTONS_OK, tips_and_tricks));
+ GtkMessageDialog *dlg = GTK_MESSAGE_DIALOG(gtk_message_dialog_new(gui_win->toplevel, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_OTHER, GTK_BUTTONS_OK, "%s", tips_and_tricks));
if (!dlg)
return;
@@ -769,12 +769,21 @@ void calf_plugins::activate_command(GtkAction *action, activate_command_params *
gui_environment::gui_environment()
{
- config_db = new calf_utils::gconf_config_db("/apps/calf");
+ keyfile = g_key_file_new();
+
+ gchar *fn = g_build_filename(getenv("HOME"), ".calfrc", NULL);
+ string filename = fn;
+ g_free(fn);
+ g_key_file_load_from_file(keyfile, filename.c_str(), (GKeyFileFlags)(G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS), NULL);
+
+ config_db = new calf_utils::gkeyfile_config_db(keyfile, filename.c_str(), "gui");
gui_config.load(config_db);
}
gui_environment::~gui_environment()
{
delete config_db;
+ if (keyfile)
+ g_key_file_free(keyfile);
}
diff --git a/src/gui_config.cpp b/src/gui_config.cpp
index 50164f8..fbd9d2b 100644
--- a/src/gui_config.cpp
+++ b/src/gui_config.cpp
@@ -1,4 +1,6 @@
#include <calf/gui_config.h>
+#include <assert.h>
+#include <stdio.h>
using namespace std;
using namespace calf_utils;
@@ -26,27 +28,33 @@ void gui_config::save(config_db_iface *db)
db->set_int("rack-rows", rows);
db->set_int("rack-cols", cols);
db->set_bool("show-rack-ears", rack_ears);
+ db->save();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-gconf_config_db::gconf_config_db(const char *parent_key)
+gkeyfile_config_db::notifier::notifier(gkeyfile_config_db *_parent, config_listener_iface *_listener)
{
- 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);
- }
- }
+ parent = _parent;
+ listener = _listener;
}
-void gconf_config_db::handle_error(GError *error)
+gkeyfile_config_db::notifier::~notifier()
+{
+ parent->remove_notifier(this);
+ }
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+gkeyfile_config_db::gkeyfile_config_db(GKeyFile *kf, const char *_filename, const char *_section)
+{
+ keyfile = kf;
+ filename = _filename;
+ section = _section;
+}
+
+void gkeyfile_config_db::handle_error(GError *error)
{
if (error)
{
@@ -56,110 +64,122 @@ void gconf_config_db::handle_error(GError *error)
}
}
-bool gconf_config_db::has_dir(const char *key)
+void gkeyfile_config_db::remove_notifier(notifier *n)
{
- GError *err = NULL;
- bool result = gconf_client_dir_exists(client, (prefix + key).c_str(), &err);
- if (err)
- handle_error(err);
- return result;
+ for (size_t i = 0; i < notifiers.size(); i++)
+ {
+ if (notifiers[i] == n)
+ {
+ notifiers.erase(notifiers.begin() + i);
+ return;
+ }
+ }
+ assert(0);
}
-bool gconf_config_db::get_bool(const char *key, bool def_value)
+bool gkeyfile_config_db::has_dir(const char *key)
{
- GError *err = NULL;
- bool value = (bool)gconf_client_get_bool(client, (prefix + key).c_str(), &err);
- if (err)
- handle_error(err);
- return value;
+ return g_key_file_has_group(keyfile, key);
}
-int gconf_config_db::get_int(const char *key, int def_value)
+static bool check_not_found_and_delete(GError *error)
{
- GError *err = NULL;
- int value = gconf_client_get_int(client, (prefix + key).c_str(), &err);
- if (err)
- handle_error(err);
- return value;
+ if (error && error->domain == G_KEY_FILE_ERROR)
+ {
+ switch(error->code)
+ {
+ case G_KEY_FILE_ERROR_KEY_NOT_FOUND:
+ case G_KEY_FILE_ERROR_GROUP_NOT_FOUND:
+ g_error_free(error);
+ return true;
+ default:
+ return false;
+ }
+ }
+ return false;
}
-std::string gconf_config_db::get_string(const char *key, const std::string &def_value)
+bool gkeyfile_config_db::get_bool(const char *key, bool def_value)
{
GError *err = NULL;
- gchar *value = (gchar *)gconf_client_get_string(client, (prefix + key).c_str(), &err);
+ bool value = (bool)g_key_file_get_boolean(keyfile, section.c_str(), key, &err);
if (err)
+ {
+ if (check_not_found_and_delete(err))
+ return def_value;
handle_error(err);
- string svalue = value;
- g_free(value);
- return svalue;
+ }
+ return value;
}
-void gconf_config_db::set_bool(const char *key, bool value)
+int gkeyfile_config_db::get_int(const char *key, int def_value)
{
GError *err = NULL;
- gconf_client_set_bool(client, (prefix + key).c_str(), (gboolean)value, &err);
+ int value = g_key_file_get_integer(keyfile, section.c_str(), key, &err);
if (err)
+ {
+ if (check_not_found_and_delete(err))
+ return def_value;
handle_error(err);
+ }
+ return value;
}
-void gconf_config_db::set_int(const char *key, int value)
+std::string gkeyfile_config_db::get_string(const char *key, const std::string &def_value)
{
GError *err = NULL;
- gconf_client_set_int(client, (prefix + key).c_str(), value, &err);
+ gchar *value = g_key_file_get_string(keyfile, section.c_str(), key, &err);
if (err)
+ {
+ if (check_not_found_and_delete(err))
+ return def_value;
handle_error(err);
+ }
+ return value;
}
-void gconf_config_db::set_string(const char *key, const std::string &value)
+void gkeyfile_config_db::set_bool(const char *key, bool value)
{
- GError *err = NULL;
- gconf_client_set_string(client, (prefix + key).c_str(), value.c_str(), &err);
- if (err)
- handle_error(err);
+ g_key_file_set_boolean(keyfile, section.c_str(), key, (gboolean)value);
}
-class gconf_notifier: public config_notifier_iface
-{
-protected:
- GConfClient *client;
- config_listener_iface *listener;
- guint notify_id;
-public:
- gconf_notifier(GConfClient *_client, config_listener_iface *_listener, const gchar *namespace_section);
- static void cb_notify(GConfClient *_client, guint cnxn_id, GConfEntry *entry, gpointer pThis);
- virtual ~gconf_notifier();
-};
-
-gconf_notifier::gconf_notifier(GConfClient *_client, config_listener_iface *_listener, const gchar *namespace_section)
+void gkeyfile_config_db::set_int(const char *key, int value)
{
- client = _client;
- listener = _listener;
- g_object_ref(G_OBJECT(client));
-
- GError *error = NULL;
- notify_id = gconf_client_notify_add(client, namespace_section, cb_notify, this, NULL, &error);
+ g_key_file_set_integer(keyfile, section.c_str(), key, value);
}
-void gconf_notifier::cb_notify(GConfClient *_client, guint cnxn_id, GConfEntry *entry, gpointer pThis)
+void gkeyfile_config_db::set_string(const char *key, const std::string &value)
{
- gconf_notifier *self = (gconf_notifier *)pThis;
- self->listener->on_config_change();
+ g_key_file_set_string(keyfile, section.c_str(), key, value.c_str());
}
-gconf_notifier::~gconf_notifier()
+void gkeyfile_config_db::save()
{
- gconf_client_notify_remove(client, notify_id);
- g_object_unref(G_OBJECT(client));
-}
+ GError *err = NULL;
+ gsize length = 0;
+ gchar *data = g_key_file_to_data(keyfile, &length, &err);
+ if (err)
+ handle_error(err);
+ if (!g_file_set_contents(filename.c_str(), data, length, &err))
+ {
+ g_free(data);
+ handle_error(err);
+ }
+ g_free(data);
+
+ for (size_t i = 0; i < notifiers.size(); i++)
+ notifiers[i]->listener->on_config_change();
+}
-config_notifier_iface *gconf_config_db::add_listener(config_listener_iface *listener)
+config_notifier_iface *gkeyfile_config_db::add_listener(config_listener_iface *listener)
{
- return new gconf_notifier(client, listener, prefix.substr(0, prefix.length() - 1).c_str());
+ notifier *n = new notifier(this, listener);
+ notifiers.push_back(n);
+ return n;
}
-gconf_config_db::~gconf_config_db()
+gkeyfile_config_db::~gkeyfile_config_db()
{
- g_object_unref(G_OBJECT(client));
}
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list