From 77bc4782c81a98ed46f342371bbff262340f2ce9 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Mon, 29 Sep 2008 22:55:35 +0000 Subject: LinGui: When the source is a file, be more intelligent about auto-naming the destination. Strip off known video extensions. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1789 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- gtk/src/callbacks.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'gtk') diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index c8d5e9cbe..90008d71a 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -362,6 +362,28 @@ camel_convert(gchar *str) } } +static gchar* +get_file_label(const gchar *filename) +{ + static gchar *containers[] = + {".vob", ".mpg", ".m2ts", ".mkv", ".mp4", ".m4v", ".avi", ".ogm", NULL}; + gchar *base; + gint ii; + + base = g_path_get_basename(filename); + for (ii = 0; containers[ii] != NULL; ii++) + { + if (g_str_has_suffix(base, containers[ii])) + { + gchar *pos; + pos = strrchr(base, '.'); + *pos = 0; + break; + } + } + return base; +} + static gboolean update_source_label(signal_user_data_t *ud, const gchar *source) { @@ -393,11 +415,7 @@ update_source_label(signal_user_data_t *ud, const gchar *source) label = ghb_dvd_volname (filename); if (label == NULL) { - path = g_strsplit(filename, "/", -1); - len = g_strv_length (path); - // Just use the last combonent of the path - label = g_strdup(path[len-1]); - g_strfreev (path); + label = get_file_label(filename); } else { -- cgit v1.2.3