[Xfce4-commits] <ristretto:master> Fix opening of directories from the command-line. - This does not recurse in the directories.
Stephan Arts
noreply at xfce.org
Mon Mar 7 22:42:01 CET 2011
Updating branch refs/heads/master
to 6bccbe2db3592915da7a5f24fbf47981c1630213 (commit)
from bc483f520caefeea1d68460aaf44b4132ed65eac (commit)
commit 6bccbe2db3592915da7a5f24fbf47981c1630213
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Mar 7 22:39:26 2011 +0100
Fix opening of directories from the command-line.
- This does not recurse in the directories.
src/main.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/src/main.c b/src/main.c
index a69c683..552f0ab 100644
--- a/src/main.c
+++ b/src/main.c
@@ -143,6 +143,7 @@ main(int argc, char **argv)
static gboolean
cb_rstto_open_files (RsttoOpenFiles *rof)
{
+ GFileType file_type;
GFile *file, *p_file, *child_file;
GFileInfo *file_info;
const gchar *content_type, *filename;
@@ -156,7 +157,15 @@ cb_rstto_open_files (RsttoOpenFiles *rof)
file = g_file_new_for_commandline_arg (rof->argv[rof->iter]);
if (file)
{
- file_info = g_file_query_info (file, "standard::content-type", 0, NULL, NULL);
+ if (rof->open_entire_folder)
+ {
+ file_info = g_file_query_info (file, "standard::content-type,standard::type", 0, NULL, NULL);
+ }
+ else
+ {
+ file_info = g_file_query_info (file, "standard::content-type", 0, NULL, NULL);
+ }
+
if (file_info)
{
content_type = g_file_info_get_attribute_string (file_info, "standard::content-type");
@@ -165,6 +174,29 @@ cb_rstto_open_files (RsttoOpenFiles *rof)
{
rstto_image_list_add_file (rof->image_list, file, NULL);
}
+
+ if (rof->open_entire_folder)
+ {
+ file_type = g_file_info_get_file_type(file_info);
+ if (file_type == G_FILE_TYPE_DIRECTORY)
+ {
+ file_enumarator = g_file_enumerate_children (file, "standard::*", 0, NULL, NULL);
+ for(file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL); file_info != NULL; file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL))
+ {
+ filename = g_file_info_get_name (file_info);
+ content_type = g_file_info_get_content_type (file_info);
+ child_file = g_file_get_child (file, filename);
+
+ if (strncmp (content_type, "image/", 6) == 0)
+ {
+ rstto_image_list_add_file (rof->image_list, child_file, NULL);
+ }
+
+ g_object_unref (child_file);
+ g_object_unref (file_info);
+ }
+ }
+ }
}
}
rof->iter++;
@@ -176,10 +208,11 @@ cb_rstto_open_files (RsttoOpenFiles *rof)
file = g_file_new_for_commandline_arg (rof->argv[rof->iter]);
if (file)
{
- file_info = g_file_query_info (file, "standard::content-type", 0, NULL, NULL);
+ file_info = g_file_query_info (file, "standard::content-type,standard::type", 0, NULL, NULL);
if (file_info)
{
content_type = g_file_info_get_attribute_string (file_info, "standard::content-type");
+ file_type = g_file_info_get_file_type (file_info);
if (strncmp (content_type, "image/", 6) == 0)
{
@@ -187,7 +220,13 @@ cb_rstto_open_files (RsttoOpenFiles *rof)
}
}
}
- p_file = g_file_get_parent (file);
+ if (file_type != G_FILE_TYPE_DIRECTORY) {
+ p_file = g_file_get_parent (file);
+ }
+ else
+ {
+ p_file = file;
+ }
file_enumarator = g_file_enumerate_children (p_file, "standard::*", 0, NULL, NULL);
for(file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL); file_info != NULL; file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL))
{
More information about the Xfce4-commits
mailing list