Mercurial > pidgin.yaz
changeset 15993:f77f1d5870b6
merge of '015699f55d664f822a057b5980abe9f7317959b7'
and 'ca14417a95631e3443b63dbefedba1709de9d78d'
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 04 Apr 2007 20:22:19 +0000 |
parents | 37d928a6579e (current diff) e78b15c2c60f (diff) |
children | bd49e48ba337 |
files | |
diffstat | 1 files changed, 106 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/libgnt/gntfilesel.c Wed Apr 04 19:18:24 2007 +0000 +++ b/finch/libgnt/gntfilesel.c Wed Apr 04 20:22:19 2007 +0000 @@ -37,6 +37,106 @@ } } +#if !GLIB_CHECK_VERSION(2,8,0) +/* ripped from glib/gfileutils.c */ +static gchar * +g_build_path_va (const gchar *separator, + gchar **str_array) +{ + GString *result; + gint separator_len = strlen (separator); + gboolean is_first = TRUE; + gboolean have_leading = FALSE; + const gchar *single_element = NULL; + const gchar *next_element; + const gchar *last_trailing = NULL; + gint i = 0; + + result = g_string_new (NULL); + + next_element = str_array[i++]; + + while (TRUE) { + const gchar *element; + const gchar *start; + const gchar *end; + + if (next_element) { + element = next_element; + next_element = str_array[i++]; + } else + break; + + /* Ignore empty elements */ + if (!*element) + continue; + + start = element; + + if (separator_len) { + while (start && + strncmp (start, separator, separator_len) == 0) + start += separator_len; + } + + end = start + strlen (start); + + if (separator_len) { + while (end >= start + separator_len && + strncmp (end - separator_len, separator, separator_len) == 0) + end -= separator_len; + + last_trailing = end; + while (last_trailing >= element + separator_len && + strncmp (last_trailing - separator_len, separator, separator_len) == 0) + last_trailing -= separator_len; + + if (!have_leading) { + /* If the leading and trailing separator strings are in the + * same element and overlap, the result is exactly that element + */ + if (last_trailing <= start) + single_element = element; + + g_string_append_len (result, element, start - element); + have_leading = TRUE; + } else + single_element = NULL; + } + + if (end == start) + continue; + + if (!is_first) + g_string_append (result, separator); + + g_string_append_len (result, start, end - start); + is_first = FALSE; + } + + if (single_element) { + g_string_free (result, TRUE); + return g_strdup (single_element); + } else { + if (last_trailing) + g_string_append (result, last_trailing); + + return g_string_free (result, FALSE); + } +} + +static gchar * +g_build_pathv (const gchar *separator, + gchar **args) +{ + if (!args) + return NULL; + + return g_build_path_va (separator, args); +} + +#endif + static char * process_path(const char *path) { @@ -259,6 +359,11 @@ path = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", sel->current, str); str = process_path(path); g_free(path); + path = str; + + if (gnt_file_sel_set_current_location(sel, path)) + goto success; + path = g_path_get_dirname(str); g_free(str); @@ -298,8 +403,8 @@ gnt_widget_draw(sel->files); } globfree(&gl); +#endif success: -#endif g_free(path); return TRUE; }