changeset 2046:040827f0b083

Primary cleanup pass.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 14 Oct 2007 00:22:43 +0300
parents 1fe4bbbdeed1
children 627e1069ef33
files src/cdaudio-ng/cdaudio-ng.c src/cdaudio-ng/configure.c src/cdaudio-ng/configure.h
diffstat 3 files changed, 176 insertions(+), 170 deletions(-) [+]
line wrap: on
line diff
--- a/src/cdaudio-ng/cdaudio-ng.c	Sat Oct 13 23:30:56 2007 +0300
+++ b/src/cdaudio-ng/cdaudio-ng.c	Sun Oct 14 00:22:43 2007 +0300
@@ -46,29 +46,20 @@
 #include "cdaudio-ng.h"
 #include "configure.h"
 
-
+struct cdng_cfg_t		cdng_cfg;
 static gint				firsttrackno = -1;
 static gint				lasttrackno = -1;
 static CdIo_t			*pcdio = NULL;
 static trackinfo_t		*trackinfo = NULL;
-
-static gboolean			use_dae = TRUE;
-static gboolean			use_cdtext = TRUE;
-static gboolean			use_cddb = TRUE;
-static gchar				*cd_device = NULL;
-static gint				limitspeed = 1;
 static gboolean			is_paused = FALSE;
 static gint				playing_track = -1;
 static dae_params_t		*pdae_params = NULL;
-static gboolean			use_debug = FALSE;
-static gchar				*cddb_server = NULL;
-static gint				cddb_port;
 static InputPlayback	*pglobalinputplayback = NULL;
 static GtkWidget		*main_menu_item, *playlist_menu_item;
 
-static void				cdaudio_init();
-static void				cdaudio_about();
-static void				cdaudio_configure();
+static void				cdaudio_init(void);
+static void				cdaudio_about(void);
+static void				cdaudio_configure(void);
 static gint				cdaudio_is_our_file(gchar *filename);
 static GList			*cdaudio_scan_dir(gchar *dirname);
 static void				cdaudio_play_file(InputPlayback *pinputplayback);
@@ -126,7 +117,7 @@
 
 void CDDEBUG(const char *fmt, ...)
 {
-	if (use_debug) {
+	if (cdng_cfg.debug) {
 		va_list ap;
 		fprintf(stderr, "cdaudio-ng: ");
 		va_start(ap, fmt);
@@ -140,9 +131,10 @@
 {
 	ConfigDb *db;
 	gchar *menu_item_text;
-	gchar *tmpstr;
 	
 	CDDEBUG("cdaudio_init()\n");
+	
+	memset(&cdng_cfg, 0, sizeof(cdng_cfg));
 
 	if ((db = aud_cfg_db_open()) == NULL) {
 		cdaudio_error("Failed to read configuration.\n");
@@ -159,27 +151,29 @@
 	libcddb_init();
 
 	/*
-	if (!aud_cfg_db_get_bool(db, "CDDA", "use_dae", &use_dae))
-		use_dae = TRUE;
+	if (!aud_cfg_db_get_bool(db, "CDDA", "use_dae", &cdng_cfg.use_dae))
+		cdng_cfg.use_dae = TRUE;
 	*/
-	if (!aud_cfg_db_get_int(db, "CDDA", "limitspeed", &limitspeed))
-		limitspeed = 1;
-	if (!aud_cfg_db_get_bool(db, "CDDA", "use_cdtext", &use_cdtext))
-		use_cdtext = TRUE;
-	if (!aud_cfg_db_get_bool(db, "CDDA", "use_cddb", &use_cddb))
-		use_cddb = TRUE;
-	if (!aud_cfg_db_get_string(db, "CDDA", "cddbserver", &cddb_server))
-		cddb_server = g_strdup(CDDA_DEFAULT_CDDB_SERVER);
-	if (!aud_cfg_db_get_int(db, "CDDA", "cddbport", &cddb_port))
-		cddb_port = CDDA_DEFAULT_CDDB_PORT;
-	if (!aud_cfg_db_get_string(db, "CDDA", "device", &cd_device))
-		cd_device = g_strdup("");
-	if (!aud_cfg_db_get_bool(db, "CDDA", "debug", &use_debug))
-		use_debug = FALSE;
+	if (!aud_cfg_db_get_int(db, "CDDA", "limitspeed", &cdng_cfg.limitspeed))
+		cdng_cfg.limitspeed = 1;
+	if (!aud_cfg_db_get_bool(db, "CDDA", "use_cdtext", &cdng_cfg.use_cdtext))
+		cdng_cfg.use_cdtext = TRUE;
+	if (!aud_cfg_db_get_bool(db, "CDDA", "use_cddb", &cdng_cfg.use_cddb))
+		cdng_cfg.use_cddb = TRUE;
+	if (!aud_cfg_db_get_string(db, "CDDA", "cddbserver", &cdng_cfg.cddb_server))
+		cdng_cfg.cddb_server = g_strdup(CDDA_DEFAULT_CDDB_SERVER);
+	if (!aud_cfg_db_get_int(db, "CDDA", "cddbport", &cdng_cfg.cddb_port))
+		cdng_cfg.cddb_port = CDDA_DEFAULT_CDDB_PORT;
+	if (!aud_cfg_db_get_string(db, "CDDA", "device", &cdng_cfg.device))
+		cdng_cfg.device = g_strdup("");
+	if (!aud_cfg_db_get_bool(db, "CDDA", "debug", &cdng_cfg.debug))
+		cdng_cfg.debug = FALSE;
 
 	aud_cfg_db_close(db);
 
-	CDDEBUG(/*use_dae = %d, */"limitspeed = %d, use_cdtext = %d, use_cddb = %d, cddbserver = \"%s\", cddbport = %d, device = \"%s\", debug = %d\n", /*use_dae, */limitspeed, use_cdtext, use_cddb, cddb_server, cddb_port, cd_device, use_debug);
+	CDDEBUG(/*use_dae = %d, */"limitspeed = %d, use_cdtext = %d, use_cddb = %d, cddbserver = \"%s\", cddbport = %d, device = \"%s\", debug = %d\n",
+	/*cdng_cfg.use_dae, */cdng_cfg.limitspeed, cdng_cfg.use_cdtext, cdng_cfg.use_cddb,
+	cdng_cfg.cddb_server, cdng_cfg.cddb_port, cdng_cfg.device, cdng_cfg.debug);
 
 	configure_create_gui();
 
@@ -272,7 +266,7 @@
 }
 
 
-static cdaudio_set_strinfo(trackinfo_t *t,
+static void cdaudio_set_strinfo(trackinfo_t *t,
 		const gchar *performer, const gchar *name, const gchar *genre)
 {
 	g_strlcpy(t->performer, performer, DEF_STRING_LEN);
@@ -281,12 +275,12 @@
 }
 
 
-static cdaudio_set_fullinfo(trackinfo_t *t,
+static void cdaudio_set_fullinfo(trackinfo_t *t,
 		const lsn_t startlsn, const lsn_t endlsn,
 		const gchar *performer, const gchar *name, const gchar *genre)
 {
-	t->startlsn = cdio_get_track_lsn(pcdrom_drive->p_cdio, 0);
-	t->endlsn = cdio_get_track_last_lsn(pcdrom_drive->p_cdio, CDIO_CDROM_LEADOUT_TRACK);
+	t->startlsn = startlsn;
+	t->endlsn = endlsn;
 	cdaudio_set_strinfo(t, performer, name, genre);
 }
 
@@ -304,10 +298,10 @@
 	}
 
 		/* find an available, audio capable, cd drive  */
-	if (cd_device != NULL && strlen(cd_device) > 0) {
-		pcdio = cdio_open(cd_device, DRIVER_UNKNOWN);
+	if (cdng_cfg.device != NULL && strlen(cdng_cfg.device) > 0) {
+		pcdio = cdio_open(cdng_cfg.device, DRIVER_UNKNOWN);
 		if (pcdio == NULL) {
-			cdaudio_error("Failed to open CD device \"%s\".\n", cd_device);
+			cdaudio_error("Failed to open CD device \"%s\".\n", cdng_cfg.device);
 			return NULL;
 		}
 	}
@@ -333,10 +327,10 @@
 	}
 
 		/* limit read speed */
-	if (limitspeed > 0 && use_dae) {
-		CDDEBUG("setting drive speed limit to %dx\n", limitspeed);
-		if (cdio_set_speed(pcdio, limitspeed) != DRIVER_OP_SUCCESS)
-			cdaudio_error("Failed to set drive speed to %dx.\n", limitspeed);
+	if (cdng_cfg.limitspeed > 0 && cdng_cfg.use_dae) {
+		CDDEBUG("setting drive speed limit to %dx\n", cdng_cfg.limitspeed);
+		if (cdio_set_speed(pcdio, cdng_cfg.limitspeed) != DRIVER_OP_SUCCESS)
+			cdaudio_error("Failed to set drive speed to %dx.\n", cdng_cfg.limitspeed);
 	}
 
 		/* get general track initialization */
@@ -376,15 +370,15 @@
 	cddb_disc_t *pcddb_disc = NULL;
 	cddb_track_t *pcddb_track = NULL;
 
-	if (use_cddb) {
+	if (cdng_cfg.use_cddb) {
 		pcddb_conn = cddb_new();
 		if (pcddb_conn == NULL)
 			cdaudio_error("Failed to create the cddb connection.\n");
 		else {
 			CDDEBUG("getting CDDB info\n");
 
-			cddb_set_server_name(pcddb_conn, cddb_server);
-			cddb_set_server_port(pcddb_conn, cddb_port);
+			cddb_set_server_name(pcddb_conn, cdng_cfg.cddb_server);
+			cddb_set_server_port(pcddb_conn, cdng_cfg.cddb_port);
 
 			pcddb_disc = cddb_disc_new();
 			for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) {
@@ -425,7 +419,7 @@
 	}
 
 		/* adding trackinfo[0] information (the disc) */
-	if (use_cdtext) {
+	if (cdng_cfg.use_cdtext) {
 		CDDEBUG("getting cd-text information for disc\n");
 		cdtext_t *pcdtext = cdio_get_cdtext(pcdrom_drive->p_cdio, 0);
 		if (pcdtext == NULL || pcdtext->field[CDTEXT_TITLE] == NULL) {
@@ -444,7 +438,7 @@
 	for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) {
 		list = g_list_append(list, g_strdup_printf("track%02u.cda", trackno));
 		cdtext_t *pcdtext = NULL;
-		if (use_cdtext) {
+		if (cdng_cfg.use_cdtext) {
 			CDDEBUG("getting cd-text information for track %d\n", trackno);
 			pcdtext = cdio_get_cdtext(pcdrom_drive->p_cdio, trackno);
 			if (pcdtext == NULL || pcdtext->field[CDTEXT_PERFORMER] == NULL) {
@@ -477,7 +471,7 @@
 
 	}
 
-	if (use_debug) {
+	if (cdng_cfg.debug) {
 		CDDEBUG("disc has : performer = \"%s\", name = \"%s\", genre = \"%s\"\n",
 			trackinfo[0].performer, trackinfo[0].name, trackinfo[0].genre);
 		
@@ -539,7 +533,7 @@
 	g_free(title);
 	aud_tuple_free(tuple);
 
-	if (use_dae) {
+	if (cdng_cfg.use_dae) {
 		CDDEBUG("using digital audio extraction\n");
 
 		if (pdae_params != NULL) {
@@ -594,7 +588,7 @@
 	playing_track = -1;
 	is_paused = FALSE;
 
-	if (use_dae) {
+	if (cdng_cfg.use_dae) {
 		if (pdae_params != NULL) {
 			g_thread_join(pdae_params->thread);
 			g_free(pdae_params);
@@ -615,7 +609,7 @@
 
 	if (!is_paused) {
 		is_paused = TRUE;
-		if (!use_dae)
+		if (!cdng_cfg.use_dae)
 			if (cdio_audio_pause(pcdio) != DRIVER_OP_SUCCESS) {
 				cdaudio_error("Failed to pause analog CD!\n");
 				cleanup_on_error();
@@ -624,7 +618,7 @@
 	}
 	else {
 		is_paused = FALSE;
-		if (!use_dae)
+		if (!cdng_cfg.use_dae)
 			if (cdio_audio_resume(pcdio) != DRIVER_OP_SUCCESS) {
 				cdaudio_error("Failed to resume analog CD!\n");
 				cleanup_on_error();
@@ -640,7 +634,7 @@
 	if (playing_track == -1)
 		return;
 
-	if (use_dae) {
+	if (cdng_cfg.use_dae) {
 		if (pdae_params != NULL) {
 			pdae_params->seektime = time * 1000;
 		}
@@ -666,7 +660,7 @@
 	if (playing_track == -1)
 		return -1;
 
-	if (!use_dae) {
+	if (!cdng_cfg.use_dae) {
 		cdio_subchannel_t subchannel;
 		if (cdio_audio_read_subchannel(pcdio, &subchannel) != DRIVER_OP_SUCCESS) {
 			cdaudio_error("Failed to read analog CD subchannel.\n");
@@ -696,7 +690,7 @@
 {
 	//printf("cdaudio-ng: cdaudio_get_volume()\n"); // annoying!
 
-	if (use_dae) {
+	if (cdng_cfg.use_dae) {
 		*l = *r = 0;
 		return FALSE;
 	}
@@ -719,7 +713,7 @@
 {
 	CDDEBUG("cdaudio_set_volume(%d, %d)\n", l, r);
 
-	if (use_dae) {
+	if (cdng_cfg.use_dae) {
 		return FALSE;
 	}
 	else {
@@ -740,8 +734,8 @@
 
 	libcddb_shutdown();
 
-	if (pcdio!= NULL) {
-		if (playing_track != -1 && !use_dae)
+	if (pcdio != NULL) {
+		if (playing_track != -1 && !cdng_cfg.use_dae)
 			cdio_audio_stop(pcdio);
 		cdio_destroy(pcdio);
 		pcdio = NULL;
@@ -755,14 +749,14 @@
 	// todo: destroy the gui
 
 	ConfigDb *db = aud_cfg_db_open();
-	/*aud_cfg_db_set_bool(db, "CDDA", "use_dae", use_dae);*/
-	aud_cfg_db_set_int(db, "CDDA", "limitspeed", limitspeed);
-	aud_cfg_db_set_bool(db, "CDDA", "use_cdtext", use_cdtext);
-	aud_cfg_db_set_bool(db, "CDDA", "use_cddb", use_cddb);
-	aud_cfg_db_set_string(db, "CDDA", "cddbserver", cddb_server);
-	aud_cfg_db_set_int(db, "CDDA", "cddbport", cddb_port);
-	aud_cfg_db_set_string(db, "CDDA", "device", cd_device);
-	aud_cfg_db_set_bool(db, "CDDA", "debug", use_debug);
+	/*aud_cfg_db_set_bool(db, "CDDA", "use_dae", cdng_cfg.use_dae);*/
+	aud_cfg_db_set_int(db, "CDDA", "limitspeed", cdng_cfg.limitspeed);
+	aud_cfg_db_set_bool(db, "CDDA", "use_cdtext", cdng_cfg.use_cdtext);
+	aud_cfg_db_set_bool(db, "CDDA", "use_cddb", cdng_cfg.use_cddb);
+	aud_cfg_db_set_string(db, "CDDA", "cddbserver", cdng_cfg.cddb_server);
+	aud_cfg_db_set_int(db, "CDDA", "cddbport", cdng_cfg.cddb_port);
+	aud_cfg_db_set_string(db, "CDDA", "device", cdng_cfg.device);
+	aud_cfg_db_set_bool(db, "CDDA", "debug", cdng_cfg.debug);
 	aud_cfg_db_close(db);
 }
 
@@ -773,7 +767,7 @@
 	gint trackno = find_trackno_from_filename(filename);
 	Tuple *tuple = create_aud_tuple_from_trackinfo(filename);
 
-	if(tuple) {
+	if (tuple) {
 		*title = aud_tuple_formatter_process_string(tuple, get_gentitle_format());
 		aud_tuple_free(tuple);
 		tuple = NULL;
--- a/src/cdaudio-ng/configure.c	Sat Oct 13 23:30:56 2007 +0300
+++ b/src/cdaudio-ng/configure.c	Sun Oct 14 00:22:43 2007 +0300
@@ -1,4 +1,3 @@
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -32,34 +31,99 @@
 		*deviceentry,
 		*debugcheckbutton;
 
-/*static gboolean			*usedae;*/
-static int				*limitspeed;
-static gboolean			*usecdtext;
-static gboolean			*usecddb;
-static char				*device;
-static gboolean			*debug;
-static char				*cddbserver;
-static int				*cddbport;
+
+static void configure_values_to_gui(void)
+{
+	gchar portstr[16];
+
+	/*gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(usedaecheckbutton), cdng_cfg.use_dae);*/
+
+	/*gtk_widget_set_sensitive(limitcheckbutton, cdng_cfg.use_dae);*/
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(limitcheckbutton), cdng_cfg.limitspeed > 0);
+
+	/*gtk_widget_set_sensitive(limitspinbutton, cdng_cfg.use_dae && cdng_cfg.limitspeed > 0);*/
+	gtk_spin_button_set_value(GTK_SPIN_BUTTON(limitspinbutton), cdng_cfg.limitspeed);
 
-static gboolean			delete_window(GtkWidget *widget, GdkEvent *event, gpointer data);
-static void				button_clicked(GtkWidget *widget, gpointer data);
-static void				checkbutton_toggled(GtkWidget *widget, gpointer data);
-static void				values_to_gui();
-static void				gui_to_values();
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(usecdtextcheckbutton), cdng_cfg.use_cdtext);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(usecddbcheckbutton), cdng_cfg.use_cddb);
+
+	gtk_entry_set_text(GTK_ENTRY(cddbserverentry), cdng_cfg.cddb_server);
+	g_snprintf(portstr, sizeof(portstr), "%d", cdng_cfg.cddb_port);
+	gtk_entry_set_text(GTK_ENTRY(cddbportentry), portstr);
+	gtk_widget_set_sensitive(cddbserverentry, cdng_cfg.use_cddb);
+	gtk_widget_set_sensitive(cddbportentry, cdng_cfg.use_cddb);
+
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(usedevicecheckbutton), strlen(cdng_cfg.device) > 0);
+
+	gtk_widget_set_sensitive(deviceentry, strlen(cdng_cfg.device) > 0);
+	gtk_entry_set_text(GTK_ENTRY(deviceentry), cdng_cfg.device);
+
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(debugcheckbutton), cdng_cfg.debug);
+}
 
 
-void configure_set_variables(/*gboolean *_usedae, */gint *_limitspeed, gboolean *_usecdtext, gboolean *_usecddb, gchar *_device, gboolean *_debug, gchar *_cddbserver, gint *_cddbport)
+static void configure_gui_to_values(void)
+{
+	/*usedae = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usedaecheckbutton));*/
+	
+	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(limitcheckbutton)))
+		cdng_cfg.limitspeed = gtk_spin_button_get_value(GTK_SPIN_BUTTON(limitspinbutton));
+	else
+		cdng_cfg.limitspeed = 0;
+	
+	cdng_cfg.use_cdtext = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usecdtextcheckbutton));
+	cdng_cfg.use_cddb = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usecddbcheckbutton));
+	pstrcpy(&cdng_cfg.cddb_server, gtk_entry_get_text(GTK_ENTRY(cddbserverentry)));
+	cdng_cfg.cddb_port = strtol(gtk_entry_get_text(GTK_ENTRY(cddbportentry)), NULL, 10);
+	
+	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usedevicecheckbutton)))
+		pstrcpy(&cdng_cfg.device, gtk_entry_get_text(GTK_ENTRY(deviceentry)));
+	else
+		pstrcpy(&cdng_cfg.device, "");
+	
+	cdng_cfg.debug = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(debugcheckbutton));
+}
+
+
+static gboolean delete_window(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
-	/*usedae = _usedae;*/
-	limitspeed = _limitspeed;
-	usecdtext = _usecdtext;
-	usecddb = _usecddb;
-	device = _device;
-	debug = _debug;
-	cddbserver = _cddbserver;
-	cddbport = _cddbport;
+	(void) widget; (void) event; (void) data;
+	gtk_widget_hide(configwindow);
+	return TRUE;
+}
+
+
+static void button_clicked(GtkWidget *widget, gpointer data)
+{
+	(void) data;
+	
+	gtk_widget_hide(configwindow);
+	if (widget == okbutton)
+		configure_gui_to_values();
 }
 
+
+static void checkbutton_toggled(GtkWidget *widget, gpointer data)
+{
+	(void) widget; (void) data;
+	
+	/*gtk_widget_set_sensitive(limitcheckbutton, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usedaecheckbutton)));*/
+
+	gtk_widget_set_sensitive(limitspinbutton,
+		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(limitcheckbutton)) &&
+		GTK_WIDGET_IS_SENSITIVE(limitcheckbutton));
+
+	gtk_widget_set_sensitive(cddbserverentry,
+		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usecddbcheckbutton)));
+	
+	gtk_widget_set_sensitive(cddbportentry,
+		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usecddbcheckbutton)));
+	
+	gtk_widget_set_sensitive(deviceentry,
+		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usedevicecheckbutton)));
+}
+
+
 void configure_create_gui()
 {
 	configwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -176,84 +240,22 @@
 	gtk_widget_show(maintable);
 }
 
-void configure_show_gui()
-{
-	values_to_gui();
-	gtk_widget_show(configwindow);
-}
 
-gboolean delete_window(GtkWidget *widget, GdkEvent *event, gpointer data)
+void configure_show_gui(void)
 {
-	gtk_widget_hide(configwindow);
-	return TRUE;
-}
-
-void button_clicked(GtkWidget *widget, gpointer data)
-{
-	gtk_widget_hide(configwindow);
-	if (widget == okbutton)
-		gui_to_values();
+	configure_values_to_gui();
+	gtk_widget_show(configwindow);
 }
 
 
-void checkbutton_toggled(GtkWidget *widget, gpointer data)
+gint pstrcpy(gchar **res, const gchar *str)
 {
-	/*gtk_widget_set_sensitive(limitcheckbutton, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usedaecheckbutton)));*/
-
-	gtk_widget_set_sensitive(
-		limitspinbutton,
-		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(limitcheckbutton)) &&
-		GTK_WIDGET_IS_SENSITIVE(limitcheckbutton));
-
-	gtk_widget_set_sensitive(cddbserverentry, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usecddbcheckbutton)));
-	gtk_widget_set_sensitive(cddbportentry, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usecddbcheckbutton)));
-
-	gtk_widget_set_sensitive(deviceentry, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usedevicecheckbutton)));
-}
-
-void values_to_gui()
-{
-	gchar portstr[16];
-
-	/*gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(usedaecheckbutton), *usedae);*/
-
-	/*gtk_widget_set_sensitive(limitcheckbutton, *usedae);*/
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(limitcheckbutton), *limitspeed > 0);
-
-	/*gtk_widget_set_sensitive(limitspinbutton, *usedae && *limitspeed > 0);*/
-	gtk_spin_button_set_value(GTK_SPIN_BUTTON(limitspinbutton), *limitspeed);
-
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(usecdtextcheckbutton), *usecdtext);
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(usecddbcheckbutton), *usecddb);
+	if (!res || !str) return -1;
 
-	g_snprintf(portstr, sizeof(portstr), "%d", *cddbport);
-	gtk_entry_set_text(GTK_ENTRY(cddbserverentry), cddbserver);
-	gtk_entry_set_text(GTK_ENTRY(cddbportentry), portstr);
-	gtk_widget_set_sensitive(cddbserverentry, *usecddb);
-	gtk_widget_set_sensitive(cddbportentry, *usecddb);
-
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(usedevicecheckbutton), strlen(device) > 0);
-
-	gtk_widget_set_sensitive(deviceentry, strlen(device) > 0);
-	gtk_entry_set_text(GTK_ENTRY(deviceentry), device);
-
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(debugcheckbutton), *debug);
-}
+	if (*res) g_free(*res);
+	if ((*res = (gchar *) g_malloc(strlen(str) + 1)) == NULL)
+		return -2;
 
-void gui_to_values()
-{
-	/*usedae = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usedaecheckbutton));*/
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(limitcheckbutton)))
-		*limitspeed = gtk_spin_button_get_value(GTK_SPIN_BUTTON(limitspinbutton));
-	else
-		*limitspeed = 0;
-	*usecdtext = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usecdtextcheckbutton));
-	*usecddb = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usecddbcheckbutton));
-	strncpy(cddbserver, gtk_entry_get_text(GTK_ENTRY(cddbserverentry)), strlen(gtk_entry_get_text(GTK_ENTRY(cddbserverentry))) + 1);
-	*cddbport = strtol(gtk_entry_get_text(GTK_ENTRY(cddbportentry)), NULL, 10);
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usedevicecheckbutton)))
-		strncpy(device, gtk_entry_get_text(GTK_ENTRY(deviceentry)), strlen(gtk_entry_get_text(GTK_ENTRY(deviceentry))) + 1);
-	else
-		strcpy(device, "");
-	*debug = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(debugcheckbutton));
+	strcpy(*res, str);
+	return 0;
 }
--- a/src/cdaudio-ng/configure.h	Sat Oct 13 23:30:56 2007 +0300
+++ b/src/cdaudio-ng/configure.h	Sun Oct 14 00:22:43 2007 +0300
@@ -1,11 +1,21 @@
-
-#ifndef CONFIGURE_H
-#define CONFIGURE_H
+#ifndef _CDNG_CONFIGURE_H
+#define _CDNG_CONFIGURE_H
+#include <glib.h>
 
-void				configure_set_variables(/*gboolean *usedae, */gint *limitspeed, gboolean *usecdtext, gboolean *usecddb, char *device, gboolean *debug, gchar *cddbserver, gint *cddbport);
-void				configure_create_gui();
-void				configure_show_gui();
+extern struct cdng_cfg_t {
+	gboolean	use_dae,
+			use_cdtext,
+			use_cddb,
+			debug;
+	gchar		*device,
+			*cddb_server;
+	gint		cddb_port,
+			limitspeed;
+} cdng_cfg;
 
 
-#endif	// CONFIGURE_H
+void	configure_create_gui(void);
+void	configure_show_gui(void);
+gint	pstrcpy(gchar **, const gchar *);
 
+#endif	// _CDNG_CONFIGURE_H