summaryrefslogtreecommitdiff
path: root/src/file-data.c
diff options
context:
space:
mode:
authorZenWalker <[email protected]>2016-06-10 10:41:11 +0200
committerZenWalker <[email protected]>2016-06-10 10:41:11 +0200
commitaf154fdd494b90adae5be5783bb725194fcf1d6b (patch)
tree251b542943ba6cee52f117ba5737c54b47f16031 /src/file-data.c
parent25c3dccb52628440615f97c9877f7dacd37d6646 (diff)
downloadengrampa-af154fdd494b90adae5be5783bb725194fcf1d6b.tar.bz2
engrampa-af154fdd494b90adae5be5783bb725194fcf1d6b.tar.xz
use natural order when sorting by filename
file-roller commit: https://git.gnome.org/browse/file-roller/commit/?id=8703609e95dcee3abbec39dea567137c7fff23e9 Fixes #143
Diffstat (limited to 'src/file-data.c')
-rw-r--r--src/file-data.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/file-data.c b/src/file-data.c
index 8905b96..d7a39a2 100644
--- a/src/file-data.c
+++ b/src/file-data.c
@@ -37,7 +37,7 @@ file_data_new (void)
fdata->content_type = NULL;
fdata->free_original_path = FALSE;
fdata->dir_size = 0;
-
+
return fdata;
}
@@ -54,6 +54,7 @@ file_data_free (FileData *fdata)
g_free (fdata->path);
g_free (fdata->link);
g_free (fdata->list_name);
+ g_free (fdata->sort_key);
g_free (fdata);
}
@@ -67,7 +68,7 @@ file_data_copy (FileData *src)
fdata->original_path = g_strdup (src->original_path);
fdata->free_original_path = TRUE;
-
+
fdata->full_path = g_strdup (src->full_path);
fdata->link = g_strdup (src->link);
fdata->size = src->size;
@@ -81,6 +82,7 @@ file_data_copy (FileData *src)
fdata->list_dir = src->list_dir;
fdata->list_name = g_strdup (src->list_name);
+ fdata->sort_key = g_strdup (src->sort_key);
return fdata;
}
@@ -90,10 +92,10 @@ GType
file_data_get_type (void)
{
static GType type = 0;
-
+
if (type == 0)
type = g_boxed_type_register_static ("FRFileData", (GBoxedCopyFunc) file_data_copy, (GBoxedFreeFunc) file_data_free);
-
+
return type;
}
@@ -101,10 +103,9 @@ file_data_get_type (void)
void
file_data_update_content_type (FileData *fdata)
{
-
- if (fdata->dir)
+ if (fdata->dir)
fdata->content_type = MIME_TYPE_DIRECTORY;
- else
+ else
fdata->content_type = get_static_string (g_content_type_guess (fdata->full_path, NULL, 0, NULL));
}
@@ -116,13 +117,28 @@ file_data_is_dir (FileData *fdata)
}
+void
+file_data_set_list_name (FileData *fdata,
+ const char *value)
+{
+ g_free (fdata->list_name);
+ fdata->list_name = g_strdup (value);
+
+ g_free (fdata->sort_key);
+ if (fdata->list_name != NULL)
+ fdata->sort_key = g_utf8_collate_key_for_filename (fdata->list_name, -1);
+ else
+ fdata->sort_key = NULL;
+}
+
+
int
file_data_compare_by_path (gconstpointer a,
gconstpointer b)
{
FileData *data_a = *((FileData **) a);
FileData *data_b = *((FileData **) b);
-
+
return strcmp (data_a->full_path, data_b->full_path);
}
@@ -158,12 +174,12 @@ find_path_in_file_data_array (GPtrArray *array,
}
if (cmp == 0)
- return p;
+ return p;
else if (cmp < 0)
right = p;
- else
+ else
left = p + 1;
}
-
+
return -1;
}