Mercurial > geeqie
changeset 403:2649a28d31b6
Introduce printf_term() macro and use it.
author | zas_ |
---|---|
date | Fri, 18 Apr 2008 09:15:09 +0000 |
parents | f6046e1b3622 |
children | d9afd1636ed8 |
files | src/collect-io.c src/main.c src/rcfile.c src/ui_bookmark.c src/ui_fileops.h |
diffstat | 5 files changed, 32 insertions(+), 84 deletions(-) [+] |
line wrap: on
line diff
--- a/src/collect-io.c Thu Apr 17 20:14:49 2008 +0000 +++ b/src/collect-io.c Fri Apr 18 09:15:09 2008 +0000 @@ -337,11 +337,7 @@ g_free(pathl); if (!ssi) { - gchar *buf; - - buf = g_strdup_printf(_("failed to open collection (write) \"%s\"\n"), path); - print_term(buf); - g_free(buf); + printf_term(_("failed to open collection (write) \"%s\"\n"), path); return FALSE; } @@ -366,12 +362,8 @@ if (secure_close(ssi)) { - gchar *buf; - - buf = g_strdup_printf(_("error saving collection file: %s\nerror: %s\n"), path, - secsave_strerror(secsave_errno)); - print_term(buf); - g_free(buf); + printf_term(_("error saving collection file: %s\nerror: %s\n"), path, + secsave_strerror(secsave_errno)); return FALSE; }
--- a/src/main.c Thu Apr 17 20:14:49 2008 +0000 +++ b/src/main.c Fri Apr 18 09:15:09 2008 +0000 @@ -420,13 +420,8 @@ n = strtod(text, NULL); if (n < SLIDESHOW_MIN_SECONDS || n > SLIDESHOW_MAX_SECONDS) { - gchar *buf; - - buf = g_strdup_printf("Remote slideshow delay out of range (%.1f to %.1f)\n", - SLIDESHOW_MIN_SECONDS, SLIDESHOW_MAX_SECONDS); - print_term(buf); - g_free(buf); - + printf_term("Remote slideshow delay out of range (%.1f to %.1f)\n", + SLIDESHOW_MIN_SECONDS, SLIDESHOW_MAX_SECONDS); return; } options->slideshow.delay = (gint)(n * 10.0 + 0.01); @@ -643,16 +638,11 @@ { if (remote_commands[i].description) { - gchar *buf; - - buf = g_strdup_printf(" %-3s%s %-20s %s\n", - (remote_commands[i].opt_s) ? remote_commands[i].opt_s : "", - (remote_commands[i].opt_s && remote_commands[i].opt_l) ? "," : " ", - (remote_commands[i].opt_l) ? remote_commands[i].opt_l : "", - _(remote_commands[i].description)); - - print_term(buf); - g_free(buf); + printf_term(" %-3s%s %-20s %s\n", + (remote_commands[i].opt_s) ? remote_commands[i].opt_s : "", + (remote_commands[i].opt_s && remote_commands[i].opt_l) ? "," : " ", + (remote_commands[i].opt_l) ? remote_commands[i].opt_l : "", + _(remote_commands[i].description)); } i++; } @@ -694,11 +684,7 @@ gint retry_count = 12; gint blank = FALSE; - { - gchar *msg = g_strdup_printf(_("Remote %s not running, starting..."), GQ_APPNAME); - print_term(msg); - g_free(msg); - } + printf_term(_("Remote %s not running, starting..."), GQ_APPNAME); command = g_string_new(arg_exec); @@ -1049,10 +1035,8 @@ else if (strcmp(cmd_line, "-h") == 0 || strcmp(cmd_line, "--help") == 0) { - gchar *usage = g_strdup_printf(_("Usage: %s [options] [path]\n\n"), GQ_APPNAME_LC); printf("%s %s\n", GQ_APPNAME, VERSION); - print_term(usage); - g_free(usage); + printf_term(_("Usage: %s [options] [path]\n\n"), GQ_APPNAME_LC); print_term(_("valid options are:\n")); print_term(_(" +t, --with-tools force show of tools\n")); print_term(_(" -t, --without-tools force hide of tools\n")); @@ -1078,11 +1062,7 @@ } else if (!remote_do) { - gchar *buf; - - buf = g_strdup_printf(_("invalid or ignored: %s\nUse --help for options\n"), cmd_line); - print_term(buf); - g_free(buf); + printf_term(_("invalid or ignored: %s\nUse --help for options\n"), cmd_line); } g_free(cmd_all); @@ -1188,17 +1168,11 @@ buf = g_strconcat(homedir(), "/", path, NULL); if (!isdir(buf)) { - gchar *tmp; - - tmp = g_strdup_printf(_("Creating %s dir:%s\n"), GQ_APPNAME, buf); - print_term(tmp); - g_free(tmp); - + printf_term(_("Creating %s dir:%s\n"), GQ_APPNAME, buf); + if (!mkdir_utf8(buf, 0755)) { - tmp = g_strdup_printf(_("Could not create dir:%s\n"), buf); - print_term(tmp); - g_free(tmp); + printf_term(_("Could not create dir:%s\n"), buf); } } g_free(buf); @@ -1392,21 +1366,11 @@ if (gtk_major_version < GTK_MAJOR_VERSION || (gtk_major_version == GTK_MAJOR_VERSION && gtk_minor_version < GTK_MINOR_VERSION) ) { - gchar *msg; - - print_term("!!! This is a friendly warning.\n"); - msg = g_strdup_printf("!!! The version of GTK+ in use now is older than when %s was compiled.\n", GQ_APPNAME); - print_term(msg); - g_free(msg); - msg = g_strdup_printf("!!! compiled with GTK+-%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION); - print_term(msg); - g_free(msg); - msg = g_strdup_printf("!!! running with GTK+-%d.%d\n", gtk_major_version, gtk_minor_version); - print_term(msg); - g_free(msg); - msg = g_strdup_printf("!!! %s may quit unexpectedly with a relocation error.\n", GQ_APPNAME); - print_term(msg); - g_free(msg); + printf_term("!!! This is a friendly warning.\n"); + printf_term("!!! The version of GTK+ in use now is older than when %s was compiled.\n", GQ_APPNAME); + printf_term("!!! compiled with GTK+-%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION); + printf_term("!!! running with GTK+-%d.%d\n", gtk_major_version, gtk_minor_version); + printf_term("!!! %s may quit unexpectedly with a relocation error.\n", GQ_APPNAME); } check_for_home_path(GQ_RC_DIR);
--- a/src/rcfile.c Thu Apr 17 20:14:49 2008 +0000 +++ b/src/rcfile.c Fri Apr 18 09:15:09 2008 +0000 @@ -273,12 +273,7 @@ g_free(rc_pathl); if (!ssi) { - gchar *buf; - - buf = g_strdup_printf(_("error saving config file: %s\n"), rc_path); - print_term(buf); - g_free(buf); - + printf_term(_("error saving config file: %s\n"), rc_path); g_free(rc_path); return; } @@ -524,13 +519,8 @@ if (secure_close(ssi)) { - gchar *buf; - - buf = g_strdup_printf(_("error saving config file: %s\nerror: %s\n"), rc_path, - secsave_strerror(secsave_errno)); - print_term(buf); - g_free(buf); - + printf_term(_("error saving config file: %s\nerror: %s\n"), rc_path, + secsave_strerror(secsave_errno)); g_free(rc_path); return; }
--- a/src/ui_bookmark.c Thu Apr 17 20:14:49 2008 +0000 +++ b/src/ui_bookmark.c Fri Apr 18 09:15:09 2008 +0000 @@ -146,12 +146,7 @@ g_free(pathl); if (!ssi) { - gchar *buf; - - buf = g_strdup_printf(_("Unable to write history lists to: %s\n"), path); - print_term(buf); - g_free(buf); - + printf_term(_("Unable to write history lists to: %s\n"), path); return FALSE; }
--- a/src/ui_fileops.h Thu Apr 17 20:14:49 2008 +0000 +++ b/src/ui_fileops.h Fri Apr 18 09:15:09 2008 +0000 @@ -23,6 +23,13 @@ void print_term(const gchar *text_utf8); +#define printf_term(...) \ + do { \ + gchar *msg = g_strdup_printf(__VA_ARGS__); \ + print_term(msg); \ + g_free(msg); \ + } while (0) + gchar *path_to_utf8(const gchar *path); gchar *path_from_utf8(const gchar *path);