changeset 1170:16d748023b2b

[gaim-migrate @ 1180] You can now choose the sound(s) you want to hear for various events. It doesnt update the preferences wnidow but it really does save them, honest! I'll fix the rest tomrrow. I'm sleepy. All Work and No play Makes Timmy TIIMMY TIimmMYY GOBBLES! committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Wed, 29 Nov 2000 10:30:56 +0000
parents 71661061013d
children 11f8829f82fb
files src/prefs.c
diffstat 1 files changed, 65 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/prefs.c	Wed Nov 29 09:28:28 2000 +0000
+++ b/src/prefs.c	Wed Nov 29 10:30:56 2000 +0000
@@ -59,6 +59,7 @@
 static void delete_prefs(GtkWidget *, void *);
 void set_default_away(GtkWidget *, gpointer);
 
+static GtkWidget *sounddialog = NULL;
 static GtkWidget *prefdialog = NULL;
 static GtkWidget *debugbutton = NULL;
 GtkWidget *prefs_away_list = NULL;
@@ -900,8 +901,71 @@
 
 static GtkWidget *sndent[NUM_SOUNDS];
 
+void close_sounddialog(GtkWidget *w, GtkWidget *w2) 
+{
+
+	GtkWidget *dest;
+	
+	if (!GTK_IS_WIDGET(w2))
+		dest = w;
+	else
+		dest = w2;
+
+	sounddialog = NULL;
+
+	gtk_widget_destroy(dest);
+}
+
+void do_select_sound(GtkWidget *w, int snd) {
+	
+	char *file;
+	
+	file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(sounddialog));
+
+	/* If they type in a directory, change there */
+	if (file_is_dir(file, sounddialog))
+		return;
+
+	/* Let's just be safe */
+	if (sound_file[snd])
+		free(sound_file[snd]);
+
+	/* Set it -- and forget it */
+	sound_file[snd] = g_strdup(file);
+
+	save_prefs();
+	
+	/* Close the window! It's getting cold in here! */
+	close_sounddialog(NULL, sounddialog);
+}
+
 static void sel_sound(GtkWidget *button, int snd) {
-	do_error_dialog("This isn't implemented yet! Ain't that a pisser? That's what you get for using CVS, I guess. So you have two options now: 1. Implement it yourself (this message should be pretty damn easy to find in the code), or 2. Hand-edit ~/.gaimrc. I suggest 2.", "Implement me!");
+	
+	char *buf = g_malloc(BUF_LEN);
+	
+	if (!sounddialog)
+	{
+		sounddialog = gtk_file_selection_new(_("Gaim - Sound Configuration"));
+
+		gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(sounddialog));
+
+		g_snprintf(buf, BUF_LEN -1, "%s/", getenv("HOME"));
+
+		gtk_file_selection_set_filename(GTK_FILE_SELECTION(sounddialog), buf);
+
+		gtk_signal_connect(GTK_OBJECT(sounddialog), "destroy", 
+				GTK_SIGNAL_FUNC(close_sounddialog), sounddialog);
+
+		gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(sounddialog)->ok_button),
+				"clicked", GTK_SIGNAL_FUNC(do_select_sound), (int *)snd);
+
+		gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(sounddialog)->cancel_button),
+				"clicked", GTK_SIGNAL_FUNC(close_sounddialog), sounddialog);
+	}
+
+	g_free(buf);
+	gtk_widget_show(sounddialog);
+	gdk_window_raise(sounddialog->window);
 }
 
 static void sound_entry(char *label, int opt, GtkWidget *box, int snd) {