changeset 19127:f34e11e41122

Made sound_pref_data a pointer
author Eric Polino <aluink@pidgin.im>
date Fri, 29 Jun 2007 21:33:43 +0000
parents ecab1e18f262
children 2c7114561553
files finch/gntsound.c
diffstat 1 files changed, 29 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntsound.c	Fri Jun 29 21:28:50 2007 +0000
+++ b/finch/gntsound.c	Fri Jun 29 21:33:43 2007 +0000
@@ -67,7 +67,7 @@
 	GntWidget *window;
 } SoundPrefDialog;
 
-static struct {
+typedef struct {
 	gchar *method;
 	gchar *command;
 	gboolean conv_focus;
@@ -75,7 +75,9 @@
 	gint volume;
 	GntTree *events;
 	SoundPrefDialog *dialog;
-} sound_pref_data;
+} SoundPrefData;
+
+SoundPrefData *sound_pref_data;
 
 #define PLAY_SOUND_TIMEOUT 15000
 
@@ -581,18 +583,18 @@
 {
 	GntTree *events = NULL;
 
-	if(sound_pref_data.method){
+	if(sound_pref_data)
 		return;
-	}
 
 	/* TODO Setup the events tree */
 
-	sound_pref_data.method = g_strdup(purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/method"));
-	sound_pref_data.command = g_strdup(purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/command"));
-	sound_pref_data.conv_focus = purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/conv_focus");
-	sound_pref_data.while_status = purple_prefs_get_int(FINCH_PREFS_ROOT "/purple/sound/while_status");
-	sound_pref_data.volume = CLAMP(purple_prefs_get_int(FINCH_PREFS_ROOT "/sound/volume"),0,100);
-	sound_pref_data.events = events;
+	sound_pref_data = g_new0(SoundPrefData,1);
+	sound_pref_data->method = g_strdup(purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/method"));
+	sound_pref_data->command = g_strdup(purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/command"));
+	sound_pref_data->conv_focus = purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/conv_focus");
+	sound_pref_data->while_status = purple_prefs_get_int(FINCH_PREFS_ROOT "/purple/sound/while_status");
+	sound_pref_data->volume = CLAMP(purple_prefs_get_int(FINCH_PREFS_ROOT "/sound/volume"),0,100);
+	sound_pref_data->events = events;
 
 	return;
 }	
@@ -615,8 +617,8 @@
 static void 
 release_pref_window(GntBindable *data, gpointer null) 
 {
-	g_free(sound_pref_data.dialog);
-	sound_pref_data.dialog = NULL;
+	g_free(sound_pref_data->dialog);
+	sound_pref_data->dialog = NULL;
 }
 
 void
@@ -631,16 +633,17 @@
 	GntWidget *label;
 	GntWidget *win;
 
-	if(sound_pref_data.dialog){
-		gnt_window_present(sound_pref_data.dialog->window);
+	init_pref_data();
+
+	if(sound_pref_data->dialog){
+		gnt_window_present(sound_pref_data->dialog->window);
 		return;
 	}
 
-	init_pref_data();
 
-	sound_pref_data.dialog = g_new0(SoundPrefDialog,1);
+	sound_pref_data->dialog = g_new0(SoundPrefDialog,1);
 
-	sound_pref_data.dialog->window = win = gnt_window_box_new(FALSE,TRUE);
+	sound_pref_data->dialog->window = win = gnt_window_box_new(FALSE,TRUE);
 	gnt_box_set_pad(GNT_BOX(win),0);
 	gnt_box_set_fill(GNT_BOX(win),FALSE);
 	gnt_box_set_toplevel(GNT_BOX(win), TRUE);
@@ -648,14 +651,14 @@
 	gnt_box_set_fill(GNT_BOX(win),TRUE);
 	gnt_box_set_alignment(GNT_BOX(win),GNT_ALIGN_MID);
 
-	sound_pref_data.dialog->method = cmbox = gnt_combo_box_new();
+	sound_pref_data->dialog->method = cmbox = gnt_combo_box_new();
 	gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"automatic",_("Automatic"));
 	gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"alsa","ALSA");
 	gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"esd","ESD");
 	gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"beep",_("Console Beep"));
 	gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"custom",_("Command"));
 	gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"nosound",_("No Sound"));
-	gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),sound_pref_data.method);
+	gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),sound_pref_data->method);
 
 	label = gnt_label_new_with_format(_("Sound Method"),GNT_TEXT_FLAG_BOLD);
 	gnt_box_add_widget(GNT_BOX(win),label); 
@@ -670,26 +673,26 @@
 	gnt_box_set_pad(GNT_BOX(box),0);
 	gnt_box_set_fill(GNT_BOX(box),FALSE);
 	gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Sound Command\n(%s for filename)")));
-	sound_pref_data.dialog->command = entry = gnt_entry_new(sound_pref_data.command);
+	sound_pref_data->dialog->command = entry = gnt_entry_new(sound_pref_data->command);
 	gnt_box_add_widget(GNT_BOX(box),entry);
 	gnt_box_add_widget(GNT_BOX(win),box);
 
 	gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE));
 
 	gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Sound Options"),GNT_TEXT_FLAG_BOLD)); 
-	sound_pref_data.dialog->conv_focus = chkbox = gnt_check_box_new("Sounds when conversation has focus");
-	gnt_check_box_set_checked(GNT_CHECK_BOX(chkbox),sound_pref_data.conv_focus);
+	sound_pref_data->dialog->conv_focus = chkbox = gnt_check_box_new("Sounds when conversation has focus");
+	gnt_check_box_set_checked(GNT_CHECK_BOX(chkbox),sound_pref_data->conv_focus);
 	gnt_box_add_widget(GNT_BOX(win),chkbox);
 
 	box = gnt_hbox_new(TRUE);
 	gnt_box_set_pad(GNT_BOX(box),0);
 	gnt_box_set_fill(GNT_BOX(box),FALSE);
 	gnt_box_add_widget(GNT_BOX(box),gnt_label_new("Enable Sounds:"));
-	sound_pref_data.dialog->while_status = cmbox = gnt_combo_box_new();
+	sound_pref_data->dialog->while_status = cmbox = gnt_combo_box_new();
 	gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"always","Always");
 	gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"available","Only when available");
 	gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"away","Only when not available");
-	switch(sound_pref_data.while_status){
+	switch(sound_pref_data->while_status){
 		case 1:gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),"available");break;
 		case 2:gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),"away");break;
 		default:gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),"always");break;
@@ -702,11 +705,11 @@
 	gnt_box_set_fill(GNT_BOX(box),FALSE);
 	gnt_box_add_widget(GNT_BOX(box),gnt_label_new("Volume(0-100):"));
 
-	sound_pref_data.dialog->volume = slider = gnt_slider_new(FALSE,100,0);
+	sound_pref_data->dialog->volume = slider = gnt_slider_new(FALSE,100,0);
 	gnt_slider_set_step(GNT_SLIDER(slider),5);
 	label = gnt_label_new("");
 	gnt_slider_reflect_label(GNT_SLIDER(slider),GNT_LABEL(label));
-	gnt_slider_set_value(GNT_SLIDER(slider),sound_pref_data.volume);
+	gnt_slider_set_value(GNT_SLIDER(slider),sound_pref_data->volume);
 	gnt_box_set_pad(GNT_BOX(box),1);
 	gnt_box_add_widget(GNT_BOX(box),slider);
 	gnt_box_add_widget(GNT_BOX(box),label);