changeset 707:41c17c66e63b

Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
author zas_
date Tue, 20 May 2008 23:07:09 +0000
parents 066b90ad9925
children 444705451f3a
files src/cache_maint.c
diffstat 1 files changed, 25 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/cache_maint.c	Tue May 20 22:47:13 2008 +0000
+++ b/src/cache_maint.c	Tue May 20 23:07:09 2008 +0000
@@ -284,7 +284,7 @@
 		cache_folder = GQ_CACHE_RC_THUMB;
 		}
 
-	base = g_strconcat(homedir(), "/", cache_folder, NULL);
+	base = g_build_filename(homedir(), cache_folder, NULL);
 
 	if (!filelist_read(base, NULL, &dlist))
 		{
@@ -430,7 +430,7 @@
 	gint still_have_a_file = FALSE;
 	GList *work;
 
-	cachedir = g_strconcat(dir, "/", GQ_CACHE_LOCAL_THUMB, NULL);
+	cachedir = g_build_filename(dir, GQ_CACHE_LOCAL_THUMB, NULL);
 
 	filelist_read(cachedir, &list, NULL);
 	work = list;
@@ -443,7 +443,7 @@
 		fd = work->data;
 		work = work->next;
 
-		source = g_strconcat(dir, "/", fd->name, NULL);
+		source = g_build_filename(dir, fd->name, NULL);
 
 		if (clear ||
 		    extension_truncate(source, GQ_CACHE_EXT_THUMB) ||
@@ -1003,19 +1003,19 @@
 
 	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("running..."));
 
-	path = g_strconcat(homedir(), "/", THUMB_FOLDER_GLOBAL, "/", THUMB_FOLDER_NORMAL, NULL);
+	path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_NORMAL, NULL);
 	list = NULL;
 	filelist_read(path, &list, NULL);
 	cd->list = list;
 	g_free(path);
 
-	path = g_strconcat(homedir(), "/", THUMB_FOLDER_GLOBAL, "/", THUMB_FOLDER_LARGE, NULL);
+	path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_LARGE, NULL);
 	list = NULL;
 	filelist_read(path, &list, NULL);
 	cd->list = g_list_concat(cd->list, list);
 	g_free(path);
 
-	path = g_strconcat(homedir(), "/", THUMB_FOLDER_GLOBAL, "/", THUMB_FOLDER_FAIL, NULL);
+	path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_FAIL, NULL);
 	list = NULL;
 	filelist_read(path, &list, NULL);
 	cd->list = g_list_concat(cd->list, list);
@@ -1149,15 +1149,29 @@
 	cache_manager = NULL;
 }
 
+static GtkWidget *cache_manager_location_label(GtkWidget *group, const gchar *subdir)
+{
+	GtkWidget *label;
+	gchar *buf;
+	gchar *path;
+
+	path = g_build_filename(homedir(), subdir, NULL);
+	buf = g_strdup_printf(_("Location: %s"), path);
+	g_free(path);
+	label = pref_label_new(group, buf);
+	g_free(buf);
+	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+	
+	return label;
+}
+
 void cache_manager_show(void)
 {
 	GenericDialog *gd;
 	GtkWidget *group;
 	GtkWidget *button;
-	GtkWidget *label;
 	GtkWidget *table;
 	GtkSizeGroup *sizegroup;
-	gchar *buf;
 
 	if (cache_manager)
 		{
@@ -1183,10 +1197,7 @@
 
 	group = pref_group_new(gd->vbox, FALSE, _("Thumbnail cache"), GTK_ORIENTATION_VERTICAL);
 
-	buf = g_strconcat(_("Location:"), " ", homedir(), "/", GQ_CACHE_RC_THUMB, NULL);
-	label = pref_label_new(group, buf);
-	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-	g_free(buf);
+	cache_manager_location_label(group, GQ_CACHE_RC_THUMB);
 
 	table = pref_table_new(group, 2, 2, FALSE, FALSE);
 
@@ -1203,10 +1214,7 @@
 
 	group = pref_group_new(gd->vbox, FALSE, _("Shared thumbnail cache"), GTK_ORIENTATION_VERTICAL);
 
-	buf = g_strconcat(_("Location:"), " ", homedir(), "/", THUMB_FOLDER_GLOBAL, NULL);
-	label = pref_label_new(group, buf);
-	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-	g_free(buf);
+	cache_manager_location_label(group, THUMB_FOLDER_GLOBAL);
 
 	table = pref_table_new(group, 2, 2, FALSE, FALSE);
 
@@ -1231,10 +1239,7 @@
 
 	group = pref_group_new(gd->vbox, FALSE, _("Metadata"), GTK_ORIENTATION_VERTICAL);
 
-	buf = g_strconcat(_("Location:"), " ", homedir(), "/", GQ_CACHE_RC_METADATA, NULL);
-	label = pref_label_new(group, buf);
-	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-	g_free(buf);
+	cache_manager_location_label(group, GQ_CACHE_RC_METADATA);
 
 	table = pref_table_new(group, 2, 1, FALSE, FALSE);