diff options
author | jstebbins <[email protected]> | 2008-09-29 22:55:35 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2008-09-29 22:55:35 +0000 |
commit | 77bc4782c81a98ed46f342371bbff262340f2ce9 (patch) | |
tree | e457ecce963f4dda28a88948d450afb4e16d3dfe /gtk | |
parent | 4e8e851f555b7f81d894739f4731f95f99435968 (diff) |
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
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/callbacks.c | 28 |
1 files changed, 23 insertions, 5 deletions
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 { |