Commit b0e0244a authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

ignore hidden files and directories when importing files

[bug #624579]
parent 8e2ab3ae
......@@ -401,8 +401,7 @@ gth_file_source_catalogs_read_metadata (GthFileSource *file_source,
gio_file = gth_catalog_file_to_gio_file (file_data->file);
files = g_list_prepend (NULL, gio_file);
_g_query_all_metadata_async (files,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
attributes,
gth_file_source_get_cancellable (file_source),
read_metadata_info_ready_cb,
......@@ -796,8 +795,7 @@ gth_file_source_catalogs_copy (GthFileSource *file_source,
}
_g_query_info_async (cod->file_list,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
GFILE_NAME_TYPE_ATTRIBUTES,
gth_file_source_get_cancellable (file_source),
copy__file_list_info_ready_cb,
......
......@@ -528,8 +528,7 @@ organization_treeview_selection_changed_cb (GtkTreeSelection *treeselection,
file_list = gth_catalog_get_file_list (catalog);
_g_query_info_async (file_list,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
GFILE_STANDARD_ATTRIBUTES_WITH_FAST_CONTENT_TYPE,
NULL,
file_list_info_ready_cb,
......
......@@ -310,8 +310,7 @@ gth_change_date_task_exec (GthTask *task)
GthChangeDateTask *self = GTH_CHANGE_DATE_TASK (task);
_g_query_all_metadata_async (self->priv->files,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
"*",
gth_task_get_cancellable (task),
info_ready_cb,
......
......@@ -144,8 +144,7 @@ dlg_edit_metadata (GthBrowser *browser,
/* FIXME: progress dialog ? */
_g_query_all_metadata_async (data->files,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
"*",
NULL,
info_ready_cb,
......
......@@ -130,8 +130,7 @@ gth_tag_task_exec (GthTask *task)
gth_task_progress (task, _("Assigning tags to the selected files"), _("Reading files"), TRUE, 0.0);
_g_query_all_metadata_async (self->priv->file_list,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
"*",
NULL,
info_ready_cb,
......
......@@ -896,8 +896,7 @@ facebook_service_upload_photos (FacebookService *self,
self->priv->post_photos->n_files = 0;
_g_query_all_metadata_async (file_list,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
"*",
self->priv->post_photos->cancellable,
upload_photos_info_ready_cb,
......
......@@ -927,8 +927,7 @@ flickr_service_post_photos (FlickrService *self,
self->priv->post_photos->n_files = 0;
_g_query_all_metadata_async (file_list,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
"*",
self->priv->post_photos->cancellable,
post_photos_info_ready_cb,
......
......@@ -157,8 +157,7 @@ transform_current_file (GthTransformTask *self)
file = self->priv->current->data;
singleton = g_list_append (NULL, g_object_ref (file));
_g_query_all_metadata_async (singleton,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
"*",
gth_task_get_cancellable (GTH_TASK (self)),
file_info_ready_cb,
......
......@@ -317,8 +317,7 @@ list_source_files (gpointer user_data)
data->loading_list = TRUE;
list = g_list_prepend (NULL, data->source);
_g_query_all_metadata_async (list,
TRUE,
TRUE,
GTH_LIST_RECURSIVE | GTH_LIST_NO_HIDDEN_FILES | GTH_LIST_NO_BACKUP_FILES,
DEFINE_STANDARD_ATTRIBUTES (",preview::icon,standard::fast-content-type,gth::file::display-size"),
data->cancellable,
list_ready_cb,
......@@ -474,6 +473,7 @@ preferences_button_clicked_cb (GtkWidget *widget,
gtk_window_present (GTK_WINDOW (data->preferences_dialog));
}
void
dlg_photo_importer (GthBrowser *browser,
GFile *source)
......
......@@ -618,8 +618,7 @@ photobucket_service_upload_photos (PhotobucketService *self,
self->priv->post_photos->n_files = 0;
_g_query_all_metadata_async (file_list,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
"*",
self->priv->post_photos->cancellable,
upload_photos_info_ready_cb,
......
......@@ -609,8 +609,7 @@ picasa_web_service_post_photos (PicasaWebService *self,
}
_g_query_all_metadata_async (file_list,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
"*",
self->priv->post_photos->cancellable,
post_photos_info_ready_cb,
......
......@@ -57,7 +57,12 @@ gth_browser_activate_action_edit_rename (GtkAction *action,
file_data_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
file_list = gth_file_data_list_to_file_list (file_data_list);
g_object_ref (browser);
_g_query_all_metadata_async (file_list, FALSE, TRUE, "*", NULL, file_list_ready_cb, browser);
_g_query_all_metadata_async (file_list,
GTH_LIST_DEFAULT,
"*",
NULL,
file_list_ready_cb,
browser);
_g_object_list_unref (file_list);
_g_object_list_unref (file_data_list);
......
......@@ -3072,8 +3072,7 @@ gth_web_exporter_exec (GthTask *task)
g_string_append (required_attributes, self->priv->sort_type->required_attributes);
}
_g_query_all_metadata_async (self->priv->gfile_list,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
required_attributes->str,
gth_task_get_cancellable (GTH_TASK (self)),
file_list_info_ready_cb,
......
......@@ -882,8 +882,7 @@ g_directory_list_async (GFile *directory,
typedef struct {
GList *file_list;
gboolean recursive;
gboolean follow_links;
GthListFlags flags;
char *attributes;
GCancellable *cancellable;
InfoReadyCallback callback;
......@@ -938,8 +937,14 @@ query_data__for_each_file_cb (GFile *file,
{
QueryInfoData *query_data = user_data;
if (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY)
query_data->files = g_list_prepend (query_data->files, gth_file_data_new (file, info));
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
return;
if ((query_data->flags & GTH_LIST_NO_BACKUP_FILES) && g_file_info_get_is_backup (info))
return;
if ((query_data->flags & GTH_LIST_NO_HIDDEN_FILES) && g_file_info_get_is_hidden (info))
return;
query_data->files = g_list_prepend (query_data->files, gth_file_data_new (file, info));
}
......@@ -951,6 +956,11 @@ query_data__start_dir_cb (GFile *directory,
{
QueryInfoData *query_data = user_data;
if ((query_data->flags & GTH_LIST_NO_BACKUP_FILES) && g_file_info_get_is_backup (info))
return DIR_OP_SKIP;
if ((query_data->flags & GTH_LIST_NO_HIDDEN_FILES) && g_file_info_get_is_hidden (info))
return DIR_OP_SKIP;
query_data->files = g_list_prepend (query_data->files, gth_file_data_new (directory, info));
return DIR_OP_CONTINUE;
......@@ -973,10 +983,10 @@ query_data_info_ready_cb (GObject *source_object,
return;
}
if (query_data->recursive && (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)) {
if ((query_data->flags & GTH_LIST_RECURSIVE) && (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)) {
g_directory_foreach_child ((GFile *) query_data->current->data,
TRUE,
query_data->follow_links,
(query_data->flags & GTH_LIST_NO_FOLLOW_LINKS) == 0,
query_data->attributes,
query_data->cancellable,
query_data__start_dir_cb,
......@@ -996,6 +1006,8 @@ query_data_info_ready_cb (GObject *source_object,
static void
query_info__query_current (QueryInfoData *query_data)
{
GFileQueryInfoFlags flags;
if (query_data->current == NULL) {
query_data->files = g_list_reverse (query_data->files);
query_data->callback (query_data->files, NULL, query_data->user_data);
......@@ -1003,9 +1015,13 @@ query_info__query_current (QueryInfoData *query_data)
return;
}
flags = G_FILE_QUERY_INFO_NONE;
if (query_data->flags & GTH_LIST_NO_FOLLOW_LINKS)
flags |= G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS;
g_file_query_info_async ((GFile *) query_data->current->data,
query_data->attributes,
(query_data->follow_links ? G_FILE_QUERY_INFO_NONE : G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS),
flags,
G_PRIORITY_DEFAULT,
query_data->cancellable,
query_data_info_ready_cb,
......@@ -1015,8 +1031,7 @@ query_info__query_current (QueryInfoData *query_data)
void
_g_query_info_async (GList *file_list,
gboolean recursive,
gboolean follow_links,
GthListFlags flags,
const char *attributes,
GCancellable *cancellable,
InfoReadyCallback ready_callback,
......@@ -1026,9 +1041,11 @@ _g_query_info_async (GList *file_list,
query_data = g_new0 (QueryInfoData, 1);
query_data->file_list = _g_object_list_ref (file_list);
query_data->recursive = recursive;
query_data->follow_links = follow_links;
query_data->attributes = g_strconcat (attributes, ",standard::name,standard::type,id::file", NULL);
query_data->flags = flags;
query_data->attributes = g_strconcat ("standard::name,standard::type,standard::is-hidden,standard::is-backup,id::file",
(((attributes != NULL) && (strcmp (attributes, "") != 0)) ? "," : NULL),
attributes,
NULL);
query_data->cancellable = _g_object_ref (cancellable);
query_data->callback = ready_callback;
query_data->user_data = user_data;
......@@ -1723,8 +1740,7 @@ _g_copy_files_async (GList *sources, /* GFile list */
copy_data->progress_callback_data);
_g_query_info_async (sources,
TRUE,
TRUE,
GTH_LIST_RECURSIVE,
"standard::name,standard::display-name,standard::type,standard::size",
copy_data->cancellable,
copy_files__sources_info_ready_cb,
......@@ -1876,7 +1892,8 @@ _g_delete_files_async (GList *file_list,
ReadyFunc callback,
gpointer user_data)
{
DeleteData *delete_data;
DeleteData *delete_data;
GthListFlags flags;
delete_data = g_new0 (DeleteData, 1);
delete_data->include_metadata = include_metadata;
......@@ -1884,9 +1901,12 @@ _g_delete_files_async (GList *file_list,
delete_data->callback = callback;
delete_data->user_data = user_data;
flags = GTH_LIST_NO_FOLLOW_LINKS;
if (recursive)
flags |= GTH_LIST_RECURSIVE;
_g_query_info_async (file_list,
recursive,
FALSE,
flags,
GFILE_NAME_TYPE_ATTRIBUTES,
delete_data->cancellable,
delete_files__info_ready_cb,
......
......@@ -39,6 +39,14 @@ typedef enum { /*< skip >*/
DIR_OP_STOP
} DirOp;
typedef enum {
GTH_LIST_DEFAULT = 0,
GTH_LIST_RECURSIVE = 1 << 0,
GTH_LIST_NO_FOLLOW_LINKS = 1 << 1,
GTH_LIST_NO_BACKUP_FILES = 1 << 2,
GTH_LIST_NO_HIDDEN_FILES = 1 << 3
} GthListFlags;
typedef DirOp (*StartDirCallback) (GFile *directory,
GFileInfo *info,
GError **error,
......@@ -86,8 +94,7 @@ void g_directory_list_async (GFile *directory,
ListReadyCallback done_func,
gpointer done_data);
void _g_query_info_async (GList *file_list, /* GFile * list */
gboolean recursive,
gboolean follow_links,
GthListFlags flags,
const char *attributes,
GCancellable *cancellable,
InfoReadyCallback ready_callback,
......
......@@ -5180,8 +5180,7 @@ _gth_browser_load_file (GthBrowser *browser,
data = load_file_data_new (browser, file_data, view);
files = g_list_prepend (NULL, data->file_data->file);
_g_query_all_metadata_async (files,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
"*",
NULL,
file_metadata_ready_cb,
......
......@@ -590,8 +590,7 @@ base_read_metadata (GthFileSource *file_source,
files = g_list_prepend (NULL, file_data->file);
_g_query_all_metadata_async (files,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
attributes,
file_source->priv->cancellable,
read_metadata_info_ready_cb,
......@@ -1076,8 +1075,7 @@ gth_file_source_read_attributes (GthFileSource *file_source,
gio_files = gth_file_source_to_gio_file_list (file_source, files);
_g_query_all_metadata_async (gio_files,
FALSE,
TRUE,
GTH_LIST_DEFAULT,
attributes,
file_source->priv->cancellable,
metadata_ready_cb,
......
......@@ -494,8 +494,7 @@ qam_info_ready_cb (GList *files,
void
_g_query_all_metadata_async (GList *files, /* GFile * list */
gboolean recursive,
gboolean follow_links,
GthListFlags flags,
const char *attributes,
GCancellable *cancellable,
InfoReadyCallback ready_func,
......@@ -510,8 +509,7 @@ _g_query_all_metadata_async (GList *files, /* GFile * list */
qam->user_data = user_data;
_g_query_info_async (files,
recursive,
follow_links,
flags,
qam->attributes,
qam->cancellable,
qam_info_ready_cb,
......
......@@ -92,8 +92,7 @@ void _g_write_metadata_async (GList *files, /* G
ReadyFunc ready_func,
gpointer user_data);
void _g_query_all_metadata_async (GList *files, /* GFile * list */
gboolean recursive,
gboolean follow_links,
GthListFlags flags,
const char *attributes,
GCancellable *cancellable,
InfoReadyCallback ready_func,
......
......@@ -318,7 +318,12 @@ gth_overwrite_dialog_construct (GthOverwriteDialog *self,
if (self->priv->source != NULL)
files = g_list_append (files, self->priv->source);
files = g_list_append (files, self->priv->destination);
_g_query_all_metadata_async (files, FALSE, TRUE, "standard::*,time::modified,time::modified-usec,preview::icon", NULL, info_ready_cb, self);
_g_query_all_metadata_async (files,
GTH_LIST_DEFAULT,
"standard::*,time::modified,time::modified-usec,preview::icon",
NULL,
info_ready_cb,
self);
g_list_free (files);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment