summary refs log tree commit diff stats
path: root/src/fe-gtk/setup.c
diff options
context:
space:
mode:
authorBerke Viktor <bviktor@hexchat.org>2013-04-28 04:12:00 +0200
committerBerke Viktor <bviktor@hexchat.org>2013-04-28 04:12:00 +0200
commita3ba8d575e972ec1ee18b29007c58276625e77d3 (patch)
treed24cef9943468d4704dfcdce4aff14fd4e7dbce3 /src/fe-gtk/setup.c
parentea48d18130e6266a8492ff53a459f3dc68b387e9 (diff)
Store just the filename if the sound file comes from the default sound dir
And get rid of some hardcoding while we're at it
Diffstat (limited to 'src/fe-gtk/setup.c')
-rw-r--r--src/fe-gtk/setup.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c
index 6a057e39..28b05d2c 100644
--- a/src/fe-gtk/setup.c
+++ b/src/fe-gtk/setup.c
@@ -1618,14 +1618,26 @@ setup_snd_filereq_cb (GtkWidget *entry, char *file)
 	if (file)
 	{
 		if (file[0])
-			gtk_entry_set_text (GTK_ENTRY (entry), file);
+		{
+			/* Use just the filename if the given sound file is in the default <config>/sounds directory.
+			 * We're comparing absolute paths so this won't work in portable mode which uses a relative path.
+			 */
+			if (!strcmp (g_path_get_dirname (file), g_build_filename (get_xdir (), HEXCHAT_SOUND_DIR, NULL)))
+			{
+				gtk_entry_set_text (GTK_ENTRY (entry), g_path_get_basename (file));
+			}
+			else
+			{
+				gtk_entry_set_text (GTK_ENTRY (entry), file);
+			}
+		}
 	}
 }
 
 static void
 setup_snd_browse_cb (GtkWidget *button, GtkEntry *entry)
 {
-	char *sounds_dir = g_build_filename (get_xdir (), "sounds", NULL);
+	char *sounds_dir = g_build_filename (get_xdir (), HEXCHAT_SOUND_DIR, NULL);
 	gtkutil_file_req (_("Select a sound file"), setup_snd_filereq_cb, entry, sounds_dir, NULL, FRF_FILTERISINITIAL);
 	g_free (sounds_dir);
 }