[balsa] Clean up file finder code
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Clean up file finder code
- Date: Sat, 27 May 2017 23:03:14 +0000 (UTC)
commit 159c3cd76cddc8a99e226a6ace0081d32ffb8126
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sat May 27 18:38:06 2017 -0400
Clean up file finder code
* libbalsa/files.c (balsa_file_finder): remove unused arguments.
* libbalsa/files.h: ditto.
ChangeLog | 7 +++++++
libbalsa/files.c | 38 +++++++++-----------------------------
libbalsa/files.h | 9 +++------
3 files changed, 19 insertions(+), 35 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2ece322..2446a9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2017-05-27 Peter Bloomfield <pbloomfield bellsouth net>
+ Clean up file finder code
+
+ * libbalsa/files.c (balsa_file_finder): remove unused arguments.
+ * libbalsa/files.h: ditto.
+
+2017-05-27 Peter Bloomfield <pbloomfield bellsouth net>
+
Remove unused code
* libinit_balsa/assistant_helper.c: remove balsa_init_get_png,
diff --git a/libbalsa/files.c b/libbalsa/files.c
index 07f39ae..afc7f1a 100644
--- a/libbalsa/files.c
+++ b/libbalsa/files.c
@@ -35,32 +35,27 @@
static const gchar *permanent_prefixes[] = {
BALSA_DATA_PREFIX,
"src",
- ".",
- NULL
+ "."
};
/* filename is the filename (naw!)
* splice is what to put in between the prefix and the filename, if desired
- * prefixes is a null-termed array of strings of prefixes to try. There are defaults that are always
- * tried.
* We ignore proper slashing of names. Ie, /prefix//splice//file won't be caught.
*/
gchar *
-balsa_file_finder(const gchar * filename, const gchar * splice,
- const gchar ** prefixes, gboolean warn)
+balsa_file_finder(const gchar * filename,
+ const gchar * splice)
{
gchar *cat;
- int i;
+ guint i;
g_return_val_if_fail(filename, NULL);
if (splice == NULL)
splice = "";
- for (i = 0; permanent_prefixes[i]; i++) {
- cat =
- g_strconcat(permanent_prefixes[i], G_DIR_SEPARATOR_S, splice,
- G_DIR_SEPARATOR_S, filename, NULL);
+ for (i = 0; i < G_N_ELEMENTS(permanent_prefixes); i++) {
+ cat = g_build_filename(permanent_prefixes[i], splice, filename, NULL);
if (g_file_test(cat, G_FILE_TEST_IS_REGULAR))
return cat;
@@ -68,28 +63,13 @@ balsa_file_finder(const gchar * filename, const gchar * splice,
g_free(cat);
}
- if(prefixes) {
- for (i = 0; prefixes[i]; i++) {
- cat =
- g_strconcat(prefixes[i], G_DIR_SEPARATOR_S, splice,
- G_DIR_SEPARATOR_S, filename, NULL);
-
- if (g_file_test(cat, G_FILE_TEST_IS_REGULAR))
- return cat;
-
- g_free(cat);
- }
- }
- cat = g_strconcat("images", G_DIR_SEPARATOR_S, filename, NULL);
+ cat = g_build_filename("images", filename, NULL);
if (g_file_test(cat, G_FILE_TEST_IS_REGULAR))
return cat;
g_free(cat);
- if (warn)
- g_warning("Cannot find expected file “%s” "
- "(spliced with “%s”) %s extra prefixes",
- filename, splice,
- prefixes ? "even with" : "with no");
+ g_warning("Cannot find expected file “%s” (spliced with “%s”)", filename, splice);
+
return NULL;
}
diff --git a/libbalsa/files.h b/libbalsa/files.h
index de4e03b..48e9b27 100644
--- a/libbalsa/files.h
+++ b/libbalsa/files.h
@@ -34,13 +34,10 @@
* We ignore proper slashing of names. Ie, /prefix//splice//file won't be caught.
*/
-gchar *balsa_file_finder(const gchar * filename, const gchar * splice,
- const gchar ** prefixes, gboolean warn);
+gchar *balsa_file_finder(const gchar * filename,
+ const gchar * splice);
-#define balsa_pixmap_finder(filename) \
- (balsa_file_finder((filename), "pixmaps", NULL, TRUE))
-#define balsa_pixmap_finder_no_warn(filename) \
- (balsa_file_finder((filename), "pixmaps", NULL, FALSE))
+#define balsa_pixmap_finder(filename) (balsa_file_finder((filename), "pixmaps"))
GdkPixbuf *libbalsa_icon_finder(GtkWidget * widget,
const char * mime_type,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]