changeset 308:511354316db4 trunk

[svn] Convert to configdb usage.
author chainsaw
date Sat, 17 Dec 2005 12:09:33 -0800
parents 894e9c4a0051
children b04ce1c98b6f
files Plugins/General/song_change/song_change.c
diffstat 1 files changed, 16 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/General/song_change/song_change.c	Sat Dec 17 11:50:41 2005 -0800
+++ b/Plugins/General/song_change/song_change.c	Sat Dec 17 12:09:33 2005 -0800
@@ -17,7 +17,7 @@
 #include <string.h>
 
 #include "audacious/plugin.h"
-#include "libaudacious/configfile.h"
+#include "libaudacious/configdb.h"
 #include "libaudacious/beepctrl.h"
 #include "libaudacious/formatter.h"
 
@@ -56,28 +56,17 @@
 
 static void read_config(void)
 {
-	ConfigFile *cfgfile;
+	ConfigDb *db;
 
-	g_free(cmd_line);
-	g_free(cmd_line_after);
-	g_free(cmd_line_end);
-	cmd_line = NULL;
-	cmd_line_after = NULL;
-	cmd_line_end = NULL;
+	cmd_line = g_strdup("");
+	cmd_line_after = g_strdup("");
+	cmd_line_end = g_strdup("");
 
-	if ((cfgfile = xmms_cfg_open_default_file()) != NULL)
-	{
-		xmms_cfg_read_string(cfgfile, "song_change", "cmd_line", &cmd_line);
-		xmms_cfg_read_string(cfgfile, "song_change", "cmd_line_after", &cmd_line_after);
-		xmms_cfg_read_string(cfgfile, "song_change", "cmd_line_end", &cmd_line_end);
-		xmms_cfg_free(cfgfile);
-	}
-	if (!cmd_line)
-		cmd_line = g_strdup("");
-	if (!cmd_line_after)
-		cmd_line_after = g_strdup("");
-	if (!cmd_line_end)
-		cmd_line_end = g_strdup("");
+	db = bmp_cfg_db_open();
+	bmp_cfg_db_get_string(db, "song_change", "cmd_line", &cmd_line);
+	bmp_cfg_db_get_string(db, "song_change", "cmd_line_after", &cmd_line_after);
+	bmp_cfg_db_get_string(db, "song_change", "cmd_line_end", &cmd_line_end);
+	bmp_cfg_db_close(db);
 }
 
 static void init(void)
@@ -105,18 +94,18 @@
 
 static void save_and_close(GtkWidget *w, gpointer data)
 {
+	ConfigDb *db;
 	char *cmd, *cmd_after, *cmd_end;
-	ConfigFile *cfgfile = xmms_cfg_open_default_file();
 
 	cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(cmd_entry)));
 	cmd_after = g_strdup(gtk_entry_get_text(GTK_ENTRY(cmd_after_entry)));
 	cmd_end = g_strdup(gtk_entry_get_text(GTK_ENTRY(cmd_end_entry)));
 
-	xmms_cfg_write_string(cfgfile, "song_change", "cmd_line", cmd);
-	xmms_cfg_write_string(cfgfile, "song_change", "cmd_line_after", cmd_after);
-	xmms_cfg_write_string(cfgfile, "song_change", "cmd_line_end", cmd_end);
-	xmms_cfg_write_default_file(cfgfile);
-	xmms_cfg_free(cfgfile);
+	db = bmp_cfg_db_open();
+	bmp_cfg_db_set_string(db, "song_change", "cmd_line", cmd);
+	bmp_cfg_db_set_string(db, "song_change", "cmd_line_after", cmd_after);
+	bmp_cfg_db_set_string(db, "song_change", "cmd_line_end", cmd_end);
+	bmp_cfg_db_close(db);
 	g_free(cmd);
 	g_free(cmd_after);
 	g_free(cmd_end);