Rename filelist_free() to file_data_list_free().
Use g_autoptr macro to simplify code a bit.
static void bar_pane_comment_set_selection(PaneCommentData *pcd, gboolean append)
{
- GList *list = nullptr;
GList *work;
g_autofree gchar *comment = text_widget_text_pull(pcd->comment_view);
- list = layout_selection_list(pcd->pane.lw);
+ g_autoptr(FileDataList) list = layout_selection_list(pcd->pane.lw);
list = file_data_process_groups_in_selection(list, FALSE, nullptr);
work = list;
metadata_write_string(fd, pcd->key, comment);
}
}
-
- filelist_free(list);
}
static void bar_pane_comment_sel_add_cb(GtkWidget *, gpointer data)
* a single, small text character the same colour as the marker background.
* Use a background process in case the user selects a large number of files.
*/
- filelist_free(pgd->selection_list);
+ file_data_list_free(pgd->selection_list);
if (pgd->bbox) champlain_bounding_box_free(pgd->bbox);
list = layout_selection_list(pgd->pane.lw);
g_idle_remove_by_data(pgd);
- filelist_free(pgd->selection_list);
+ file_data_list_free(pgd->selection_list);
if (pgd->bbox) champlain_bounding_box_free(pgd->bbox);
file_data_unref(pgd->fd);
void bar_pane_keywords_set_selection(PaneKeywordsData *pkd, gboolean append)
{
GList *keywords = nullptr;
- GList *list = nullptr;
GList *work;
keywords = keyword_list_pull_selected(pkd->keyword_view);
- list = layout_selection_list(pkd->pane.lw);
+ g_autoptr(FileDataList) list = layout_selection_list(pkd->pane.lw);
list = file_data_process_groups_in_selection(list, FALSE, nullptr);
work = list;
}
}
- filelist_free(list);
g_list_free_full(keywords, g_free);
}
work = work->next;
metadata_append_list(fd, KEYWORD_KEY, keywords);
}
- filelist_free(list);
+ file_data_list_free(list);
g_list_free_full(keywords, g_free);
}
static void bar_sort_collection_list_build(GtkWidget *bookmarks)
{
FileData *dir_fd;
- GList *list;
GList *work;
history_list_free_key(SORT_KEY_COLLECTIONS);
bookmark_list_set_key(bookmarks, SORT_KEY_COLLECTIONS);
dir_fd = file_data_new_dir(get_collections_dir());
+ g_autoptr(FileDataList) list = nullptr;
filelist_read(dir_fd, &list, nullptr);
file_data_unref(dir_fd);
}
bookmark_list_add(bookmarks, name, fd->path);
}
-
- filelist_free(list);
}
static void bar_sort_mode_sync(SortData *sd, SortModeType mode)
{
if (cm->idle_id) g_source_remove(cm->idle_id);
if (cm->gd) generic_dialog_close(cm->gd);
- filelist_free(cm->list);
+ file_data_list_free(cm->list);
g_list_free(cm->done_list);
g_free(cm);
}
}
options->file_filter.disable = filter_disable;
- filelist_free(list);
+ file_data_list_free(list);
cm->list = g_list_concat(dlist, cm->list);
static void cache_manager_render_reset(CacheOpsData *cd)
{
- filelist_free(cd->list);
+ file_data_list_free(cd->list);
cd->list = nullptr;
- filelist_free(cd->list_dir);
+ file_data_list_free(cd->list_dir);
cd->list_dir = nullptr;
thumb_loader_free(reinterpret_cast<ThumbLoader *>(cd->tl));
generic_dialog_close(cd->gd);
thumb_loader_std_thumb_file_validate_cancel(cd->tl);
- filelist_free(cd->list);
+ file_data_list_free(cd->list);
g_free(cd);
}
thumb_loader_std_thumb_file_validate_cancel(cd->tl);
cd->tl = nullptr;
- filelist_free(cd->list);
+ file_data_list_free(cd->list);
cd->list = nullptr;
}
static void cache_manager_sim_reset(CacheOpsData *cd)
{
- filelist_free(cd->list);
+ file_data_list_free(cd->list);
cd->list = nullptr;
- filelist_free(cd->list_dir);
+ file_data_list_free(cd->list_dir);
cd->list_dir = nullptr;
cache_loader_free(cd->cl);
static void collect_manager_refresh()
{
- GList *list;
GList *work;
FileData *dir_fd;
dir_fd = file_data_new_dir(get_collections_dir());
+ g_autoptr(FileDataList) list = nullptr;
filelist_read(dir_fd, &list, nullptr);
file_data_unref(dir_fd);
collect_manager_entry_new(fd->path);
}
-
- filelist_free(list);
}
static void collect_manager_process_actions(gint max)
void collect_manager_list(GList **names_exc, GList **names_inc, GList **paths)
{
FileData *dir_fd;
- GList *list = nullptr;
if (names_exc == nullptr && names_inc == nullptr && paths == nullptr)
{
dir_fd = file_data_new_dir((get_collections_dir()));
+ g_autoptr(FileDataList) list = nullptr;
filelist_read(dir_fd, &list, nullptr);
for (GList *work = list; work; work = work->next)
}
}
}
-
- filelist_free(list);
}
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
static void collection_table_popup_add_file_selection_cb(GtkWidget *, gpointer data)
{
auto ct = static_cast<CollectTable *>(data);
- GList *list;
LayoutWindow *lw = get_current_layout();
if (!lw) return;
- list = vf_selection_get_list(lw->vf);
+ g_autoptr(FileDataList) list = vf_selection_get_list(lw->vf);
+ if (!list) return;
- if (list)
- {
- collection_table_add_filelist(ct, list);
- filelist_free(list);
- }
+ collection_table_add_filelist(ct, list);
}
static void collection_table_popup_add_collection_cb(GtkWidget *, gpointer data)
ct->click_info = nullptr;
ct->popup = nullptr;
- filelist_free(ct->drop_list);
+ file_data_list_free(ct->drop_list);
ct->drop_list = nullptr;
ct->drop_info = nullptr;
- filelist_free(ct->editmenu_fd_list);
+ file_data_list_free(ct->editmenu_fd_list);
ct->editmenu_fd_list = nullptr;
}
work = work->prev;
}
- filelist_free(f);
- filelist_free(d);
+ file_data_list_free(f);
+ file_data_list_free(d);
}
static void confirm_dir_list_do(CollectTable *ct, GList *list, gboolean recursive)
if (!list) return;
uri_selection_data_set_uris_from_filelist(selection_data, list);
- filelist_free(list);
+ file_data_list_free(list);
break;
}
}
gint col = -1;
/* it is a move within a collection */
- filelist_free(list);
+ file_data_list_free(list);
list = nullptr;
if (!drop_info)
if (list)
{
collection_table_insert_filelist(ct, list, drop_info);
- filelist_free(list);
+ file_data_list_free(list);
}
}
{
auto cw = static_cast<CollectWindow *>(data);
gboolean stop_signal = TRUE;
- GList *list;
if (event->state & GDK_CONTROL_MASK)
{
}
break;
case 'L': case 'l':
- list = layout_list(nullptr);
+ {
+ g_autoptr(FileDataList) list = layout_list(nullptr);
if (list)
{
collection_table_add_filelist(cw->table, list);
- filelist_free(list);
}
+ }
break;
case 'C': case 'c':
file_util_copy(nullptr, collection_table_selection_get_list(cw->table), nullptr, cw->window);
}
break;
case GDK_KEY_Delete: case GDK_KEY_KP_Delete:
- list = g_list_copy(cw->table->selection);
+ {
+ g_autoptr(GList) list = g_list_copy(cw->table->selection);
if (list)
{
collection_remove_by_info_list(cw->cd, list);
collection_table_refresh(cw->table);
- g_list_free(list);
}
else
{
collection_remove_by_info(cw->cd, collection_table_get_focus_info(cw->table));
}
+ }
break;
default:
stop_signal = FALSE;
void get_filelist(GApplicationCommandLine *app_command_line, const gchar *text, gboolean recurse)
{
- GList *list = nullptr;
FileFormatClass format_class;
FileData *dir_fd;
FileData *fd;
dir_fd = file_data_new_dir(tilde_filename);
}
+ g_autoptr(FileDataList) list = nullptr;
if (recurse)
{
list = filelist_recursive(dir_fd);
g_application_command_line_print(app_command_line, "%s\n", out_string->str);
- filelist_free(list);
file_data_unref(dir_fd);
}
{
if (!layout_valid(&lw_id)) return;
- GList *selected = layout_selection_list(lw_id); // Keep copy to free.
+ g_autoptr(FileDataList) selected = layout_selection_list(lw_id); // Keep copy to free.
g_autoptr(GString) out_string = g_string_new(nullptr);
GList *work = selected;
}
g_application_command_line_print(app_command_line, "%s\n", out_string->str);
-
- filelist_free(selected);
}
g_autofree gchar *filename = g_path_get_basename(path);
g_autofree gchar *slash_plus_filename = g_strdup_printf("%s%s", G_DIR_SEPARATOR_S, filename);
- GList *file_list = layout_list(lw_id);
+ g_autoptr(FileDataList) file_list = layout_list(lw_id);
for (GList *work = file_list; work && !fd_to_select; work = work->next)
{
auto fd = static_cast<FileData *>(work->data);
g_application_command_line_print(app_command_line, "File " BOLD_ON "%s" BOLD_OFF " is not in the current folder " BOLD_ON "%s" BOLD_OFF "%c",
filename, g_application_command_line_get_cwd(app_command_line), print0 ? 0 : '\n');
}
-
- filelist_free(file_list);
}
if (fd_to_select)
{
- GList *to_select = g_list_append(nullptr, fd_to_select);
+ g_autoptr(FileDataList) to_select = g_list_append(nullptr, fd_to_select);
// Using the "_list" variant doesn't clear the existing selection.
layout_select_list(lw_id, to_select);
- filelist_free(to_select);
}
}
fd_to_deselect = layout_image_get_fd(lw_id);
if (!fd_to_deselect)
{
- filelist_free(selected);
+ file_data_list_free(selected);
g_application_command_line_print(app_command_line, _("remote sent \"--selection-remove:\" with no current image\n"));
return;
}
{
// Remove first link.
selected = g_list_remove_link(selected, link_to_remove);
- filelist_free(link_to_remove);
- link_to_remove = nullptr;
}
else
{
// Remove a subsequent link.
prior_link = g_list_remove_link(prior_link, link_to_remove);
- filelist_free(link_to_remove);
- link_to_remove = nullptr;
}
+ file_data_list_free(link_to_remove);
+ link_to_remove = nullptr;
+
// Re-select all but the deselected item.
layout_select_none(lw_id);
layout_select_list(lw_id, selected);
}
- filelist_free(selected);
+ file_data_list_free(selected);
file_data_unref(fd_to_deselect);
}
gtk_widget_set_sensitive(dw->controls_box, TRUE);
if (g_list_length(dw->add_files_queue) > 0)
{
- filelist_free(dw->add_files_queue);
+ file_data_list_free(dw->add_files_queue);
}
dw->add_files_queue = nullptr;
dupe_window_update_progress(dw, nullptr, 0.0, FALSE);
dupe_files_add(dw, nullptr, static_cast<FileData *>(work->data), TRUE);
work = work->next;
}
- filelist_free(f);
+ file_data_list_free(f);
work = d;
while (work)
{
dupe_files_add(dw, nullptr, static_cast<FileData *>(work->data), TRUE);
work = work->next;
}
- filelist_free(d);
+ file_data_list_free(d);
}
}
}
{
if (new_window)
{
- GList *list = dupe_listview_get_selection(listview);
+ g_autoptr(FileDataList) list = dupe_listview_get_selection(listview);
view_window_new_from_list(list);
- filelist_free(list);
}
else
{
static void dupe_window_collection_from_selection(DupeWindow *dw)
{
CollectWindow *w = collection_window_new(nullptr);
- GList *list = dupe_listview_get_selection(dw->listview);
+ g_autoptr(FileDataList) list = dupe_listview_get_selection(dw->listview);
collection_table_add_filelist(w->table, list);
- filelist_free(list);
}
static void dupe_window_append_file_list(DupeWindow *dw, gint on_second)
{
- GList *list;
-
dw->second_drop = (dw->second_set && on_second);
- list = layout_list(nullptr);
+ g_autoptr(FileDataList) list = layout_list(nullptr);
dupe_window_add_files(dw, list, FALSE);
- filelist_free(list);
}
/*
{
auto editmenu_fd_list = static_cast<GList *>(data);
- filelist_free(editmenu_fd_list);
+ file_data_list_free(editmenu_fd_list);
}
static GList *dupe_window_get_fd_list(DupeWindow *dw)
{
auto *dw = static_cast<DupeWindow *>(submenu_item_get_data(widget));
- GList *selection_list = dupe_listview_get_selection(dw->listview);
+ g_autoptr(FileDataList) selection_list = dupe_listview_get_selection(dw->listview);
pop_menu_collections(selection_list, data);
-
- filelist_free(selection_list);
}
static GtkWidget *dupe_menu_popup_main(DupeWindow *dw, DupeItem *di)
work = work->next;
if (isdir(fd->path))
{
- GList *list;
+ g_autoptr(FileDataList) list = nullptr;
filelist_read(fd, &list, nullptr);
list = filelist_filter(list, FALSE);
if (list)
{
dupe_window_add_files(d->dw, list, FALSE);
- filelist_free(list);
}
}
}
static void confirm_dir_list_destroy(GtkWidget *, gpointer data)
{
auto d = static_cast<CDupeConfirmD *>(data);
- filelist_free(d->list);
+ file_data_list_free(d->list);
g_free(d);
}
GtkSelectionData *selection_data, guint info,
guint, gpointer)
{
- GList *list;
-
switch (info)
{
case TARGET_URI_LIST:
case TARGET_TEXT_PLAIN:
- list = dupe_listview_get_selection(widget);
+ {
+ g_autoptr(FileDataList) list = dupe_listview_get_selection(widget);
if (!list) return;
+
uri_selection_data_set_uris_from_filelist(selection_data, list);
- filelist_free(list);
+ }
break;
default:
break;
{
auto dw = static_cast<DupeWindow *>(data);
GtkWidget *source;
- GList *list = nullptr;
GList *work;
if (dw->add_files_queue_id > 0)
dw->second_drop = (dw->second_set && widget == dw->second_listview);
+ g_autoptr(FileDataList) list = nullptr;
switch (info)
{
case TARGET_APP_COLLECTION_MEMBER:
if (list)
{
dupe_window_add_files(dw, list, FALSE);
- filelist_free(list);
}
}
if (ed->flags & EDITOR_FOR_EACH)
{
/* handle the first element from the list */
- GList *fd_element = ed->list;
+ g_autoptr(FileDataList) fd_element = ed->list;
ed->list = g_list_remove_link(ed->list, fd_element);
if (ed->callback)
cont = ed->callback(ed->list ? ed : nullptr, ed->flags, fd_element, ed->data);
if (ed->stopping && cont == EDITOR_CB_CONTINUE) cont = EDITOR_CB_SKIP;
}
- filelist_free(fd_element);
}
else
{
/* handle whole list */
if (ed->callback)
cont = ed->callback(nullptr, ed->flags, ed->list, ed->data);
- filelist_free(ed->list);
+ file_data_list_free(ed->list);
ed->list = nullptr;
}
{
ed->flags = static_cast<EditorFlags>(ed->flags | EDITOR_ERROR_SKIPPED);
if (ed->callback) ed->callback(nullptr, ed->flags, ed->list, ed->data);
- filelist_free(ed->list);
+ file_data_list_free(ed->list);
ed->list = nullptr;
}
return FileData::FileList::read_list_lstat(dir_fd, files, dirs);
}
-void filelist_free(GList *list)
+void file_data_list_free(FileDataList *list)
{
FileData::FileList::free_list(list);
}
void file_data_unref(FileData *fd);
#endif
+using FileDataList = GList; // element is FileData
+
void file_data_lock(FileData *fd);
void file_data_unlock(FileData *fd);
void file_data_lock_list(GList *list);
gboolean filelist_read(FileData *dir_fd, GList **files, GList **dirs);
gboolean filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs);
-void filelist_free(GList *list);
+
+void file_data_list_free(FileDataList *list);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(FileDataList, file_data_list_free)
+
GList *filelist_copy(GList *list);
GList *filelist_from_path_list(GList *list);
GList *filelist_to_path_list(GList *list);
}
file_data_check_sidecars(sidecars); /* this will group the sidecars back together */
/* now we can release the sidecars */
- filelist_free(sidecars);
+ file_data_list_free(sidecars);
file_data_increment_version(fd);
file_data_send_notification(fd, NOTIFY_REREAD);
::file_data_unref(fd);
}
else if (fd->sidecar_files)
{
- GList *sidecar_files = filelist_copy(fd->sidecar_files);
+ g_autoptr(FileDataList) sidecar_files = filelist_copy(fd->sidecar_files);
GList *work = sidecar_files;
while (work)
{
file_data_send_notification(sfd, NOTIFY_GROUPING);
}
file_data_check_sidecars(sidecar_files); /* this will group the sidecars back together */
- filelist_free(sidecar_files);
}
else
{
void FileData::file_data_basename_hash_remove_list(gpointer, gpointer value, gpointer)
{
- filelist_free(static_cast<GList *>(value));
+ file_data_list_free(static_cast<GList *>(value));
}
void FileData::file_data_basename_hash_free(GHashTable *basename_hash)
g_autofree gchar *dir = remove_level_from_path(path_utf8);
- GList *files;
+ g_autoptr(FileDataList) files = nullptr;
FileList::read_list_real(dir, &files, nullptr, TRUE);
auto *fd = static_cast<FileData *>(g_hash_table_lookup(context->file_data_pool, path_utf8));
::file_data_ref(fd);
}
- filelist_free(files);
return fd;
}
}
}
- filelist_free(list);
+ file_data_list_free(list);
out = g_list_reverse(out);
return out;
static void view_window_set_list(ViewWindow *vw, GList *list)
{
- filelist_free(vw->list);
+ file_data_list_free(vw->list);
vw->list = nullptr;
vw->list_pointer = nullptr;
view_slideshow_stop(vw);
fullscreen_stop(vw->fs);
- filelist_free(vw->list);
+ file_data_list_free(vw->list);
file_data_unregister_notify_func(view_window_notify_cb, vw);
list = filelist_sort_path(list);
list = filelist_filter(list, FALSE);
real_view_window_new(nullptr, list, nullptr, nullptr);
- filelist_free(list);
+ file_data_list_free(list);
}
else
{
{
auto editmenu_fd_list = static_cast<GList *>(data);
- filelist_free(editmenu_fd_list);
+ file_data_list_free(editmenu_fd_list);
}
static GList *view_window_get_fd_list(ViewWindow *vw)
ViewWindow *vw;
ImageWindow *imd;
FileData *fd;
- GList *selection_list = nullptr;
vw = static_cast<ViewWindow *>(submenu_item_get_data(widget));
imd = view_window_active_image(vw);
fd = image_get_fd(imd);
- selection_list = g_list_append(selection_list, fd);
- pop_menu_collections(selection_list, data);
- filelist_free(selection_list);
+ g_autoptr(FileDataList) selection_list = g_list_append(nullptr, fd);
+ pop_menu_collections(selection_list, data);
}
static GtkWidget *view_popup_menu(ViewWindow *vw)
static void view_dir_list_destroy(GtkWidget *, gpointer data)
{
auto d = static_cast<CViewConfirmD *>(data);
- filelist_free(d->list);
+ file_data_list_free(d->list);
g_free(d);
}
if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER)
{
CollectionData *source;
- GList *list;
+ g_autoptr(FileDataList) list = nullptr;
GList *info_list;
if (info == TARGET_URI_LIST)
}
}
}
- filelist_free(list);
+
g_list_free(info_list);
}
}
if (lw->slideshow || !list)
{
- filelist_free(list);
+ file_data_list_free(list);
return;
}
{
auto editmenu_fd_list = static_cast<GList *>(data);
- filelist_free(editmenu_fd_list);
+ file_data_list_free(editmenu_fd_list);
}
static GList *layout_image_get_fd_list(LayoutWindow *lw)
*/
static void layout_pop_menu_collections_cb(GtkWidget *widget, gpointer data)
{
- LayoutWindow *lw;
- GList *selection_list = nullptr;
+ auto *lw = static_cast<LayoutWindow *>(submenu_item_get_data(widget));
- lw = static_cast<LayoutWindow *>(submenu_item_get_data(widget));
- selection_list = g_list_append(selection_list, layout_image_get_fd(lw));
+ g_autoptr(FileDataList) selection_list = g_list_append(nullptr, layout_image_get_fd(lw));
pop_menu_collections(selection_list, data);
-
- filelist_free(selection_list);
}
static void li_pop_menu_selectable_toolbars_toggle_cb(GtkWidget *, gpointer)
else if (info == TARGET_URI_LIST || info == TARGET_APP_COLLECTION_MEMBER)
{
CollectionData *source;
- GList *list;
+ g_autoptr(FileDataList) list = nullptr;
GList *info_list;
if (info == TARGET_URI_LIST)
}
}
- filelist_free(list);
g_list_free(info_list);
}
}
}
g_list_free(f);
- filelist_free(d);
+ file_data_list_free(d);
return group;
}
}
}
- filelist_free(d);
+ file_data_list_free(d);
pan_item_size_by_item(parent, pi_box, PAN_BOX_BORDER);
g_list_free_full(pw->cache_list, reinterpret_cast<GDestroyNotify>(pan_cache_data_free));
pw->cache_list = nullptr;
- filelist_free(pw->cache_todo);
+ file_data_list_free(pw->cache_todo);
pw->cache_todo = nullptr;
pw->cache_count = 0;
{
auto editmenu_fd_list = static_cast<GList *>(data);
- filelist_free(editmenu_fd_list);
+ file_data_list_free(editmenu_fd_list);
}
static void pan_play_cb(GtkWidget *, gpointer data)
*/
static void pan_pop_menu_collections_cb(GtkWidget *widget, gpointer data)
{
- PanWindow *pw;
- GList *selection_list = nullptr;
+ auto *pw = static_cast<PanWindow *>(submenu_item_get_data(widget));
- pw = static_cast<PanWindow *>(submenu_item_get_data(widget));
- selection_list = g_list_append(selection_list, pan_menu_click_fd(pw));
+ g_autoptr(FileDataList) selection_list = g_list_append(nullptr, pan_menu_click_fd(pw));
pop_menu_collections(selection_list, data);
-
- filelist_free(selection_list);
}
static GtkWidget *pan_popup_menu(PanWindow *pw)
if (info == TARGET_URI_LIST)
{
- GList *list;
-
- list = uri_filelist_from_gtk_selection_data(selection_data);
+ g_autoptr(FileDataList) list = uri_filelist_from_gtk_selection_data(selection_data);
if (list && isdir((static_cast<FileData *>(list->data))->path))
{
auto fd = static_cast<FileData *>(list->data);
pan_layout_set_fd(pw, fd);
}
-
- filelist_free(list);
}
}
static void keywords_find_reset(KeywordFindData *kfd)
{
- filelist_free(kfd->list);
+ file_data_list_free(kfd->list);
kfd->list = nullptr;
- filelist_free(kfd->list_dir);
+ file_data_list_free(kfd->list_dir);
kfd->list_dir = nullptr;
}
static void search_result_collection_from_selection(SearchData *sd)
{
CollectWindow *w;
- GList *list;
- list = search_result_selection_list(sd);
+ g_autoptr(FileDataList) list = search_result_selection_list(sd);
w = collection_window_new(nullptr);
collection_table_add_filelist(w->table, list);
- filelist_free(list);
}
static gboolean search_result_update_idle_cb(gpointer data)
static void sr_menu_viewnew_cb(GtkWidget *, gpointer data)
{
auto sd = static_cast<SearchData *>(data);
- GList *list;
- list = search_result_selection_list(sd);
+ g_autoptr(FileDataList) list = search_result_selection_list(sd);
view_window_new_from_list(list);
- filelist_free(list);
}
static void sr_menu_select_all_cb(GtkWidget *, gpointer data)
{
auto editmenu_fd_list = static_cast<GList *>(data);
- filelist_free(editmenu_fd_list);
+ file_data_list_free(editmenu_fd_list);
}
/**
* @param[in] widget
* @param[in] data Index to the collection list menu item selected, or -1 for new collection
*
- *
*/
static void search_pop_menu_collections_cb(GtkWidget *widget, gpointer data)
{
- SearchData *sd;
- GList *selection_list;
+ auto *sd = static_cast<SearchData *>(submenu_item_get_data(widget));
- sd = static_cast<SearchData *>(submenu_item_get_data(widget));
- selection_list = search_result_selection_list(sd);
+ g_autoptr(FileDataList) selection_list = search_result_selection_list(sd);
pop_menu_collections(selection_list, data);
-
- filelist_free(selection_list);
}
static GtkWidget *search_result_menu(SearchData *sd, gboolean on_row, gboolean empty)
break;
case 'V': case 'v':
{
- GList *list;
-
- list = search_result_selection_list(sd);
+ g_autoptr(FileDataList) list = search_result_selection_list(sd);
view_window_new_from_list(list);
- filelist_free(list);
}
break;
case GDK_KEY_Delete: case GDK_KEY_KP_Delete:
guint, gpointer data)
{
auto sd = static_cast<SearchData *>(data);
- GList *list;
- list = search_result_selection_list(sd);
+ g_autoptr(FileDataList) list = search_result_selection_list(sd);
if (!list) return;
uri_selection_data_set_uris_from_filelist(selection_data, list);
- filelist_free(list);
}
static void search_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
search_buffer_flush(sd);
- filelist_free(sd->search_folder_list);
+ file_data_list_free(sd->search_folder_list);
sd->search_folder_list = nullptr;
g_list_free(sd->search_done_list);
sd->search_done_list = nullptr;
- filelist_free(sd->search_file_list);
+ file_data_list_free(sd->search_file_list);
sd->search_file_list = nullptr;
sd->match_broken_enable = FALSE;
}
else
{
- filelist_free(dlist);
+ file_data_list_free(dlist);
}
}
}
if (ss->stop_func) ss->stop_func(ss, ss->stop_data);
- if (ss->filelist) filelist_free(ss->filelist);
+ if (ss->filelist) file_data_list_free(ss->filelist);
if (ss->cd) collection_unref(ss->cd);
file_data_unref(ss->dir_fd);
{
gint n = 0;
gint64 total = 0;
- GList *list;
GList *work;
gboolean sorted = FALSE;
gboolean warned = FALSE;
FileData *dir_fd;
dir_fd = file_data_new_dir(options->file_ops.safe_delete_path);
+ g_autoptr(FileDataList) list = nullptr;
if (!filelist_read(dir_fd, &list, nullptr))
{
file_data_unref(dir_fd);
file_data_unref(fd);
}
- filelist_free(list);
-
return n;
}
{
file_data_unref(fdlg->source_fd);
g_free(fdlg->dest_path);
- if (fdlg->source_list) filelist_free(fdlg->source_list);
+ if (fdlg->source_list) file_data_list_free(fdlg->source_list);
generic_dialog_close(GENERIC_DIALOG(fdlg));
}
if (ud->perform_idle_id) g_source_remove(ud->perform_idle_id);
file_data_unref(ud->dir_fd);
- filelist_free(ud->content_list);
- filelist_free(ud->flist);
+ file_data_list_free(ud->content_list);
+ file_data_list_free(ud->flist);
if (ud->gd) generic_dialog_close(ud->gd);
static void file_util_delete_full(FileData *source_fd, GList *flist, GtkWidget *parent, UtilityPhase phase, FileUtilDoneFunc done_func, gpointer done_data)
{
UtilityData *ud;
- GList *ungrouped = nullptr;
gchar *message;
if (source_fd)
if (!flist) return;
+ g_autoptr(FileDataList) ungrouped = nullptr;
flist = file_data_process_groups_in_selection(flist, TRUE, &ungrouped);
if (!file_data_sc_add_ci_delete_list(flist))
{
file_util_warn_op_in_progress(_("File deletion failed"));
file_data_disable_grouping_list(ungrouped, FALSE);
- filelist_free(flist);
- filelist_free(ungrouped);
+ file_data_list_free(flist);
return;
}
file_util_mark_ungrouped_files(ungrouped);
- filelist_free(ungrouped);
ud = file_util_data_new(UtilityType::DELETE);
if (!file_data_add_ci_write_metadata_list(flist))
{
file_util_warn_op_in_progress(_("Can't write metadata"));
- filelist_free(flist);
+ file_data_list_free(flist);
return;
}
static void file_util_move_full(FileData *source_fd, GList *flist, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase)
{
UtilityData *ud;
- GList *ungrouped = nullptr;
if (source_fd)
flist = g_list_append(flist, file_data_ref(source_fd));
if (!flist) return;
+ g_autoptr(FileDataList) ungrouped = nullptr;
flist = file_data_process_groups_in_selection(flist, TRUE, &ungrouped);
if (!file_data_sc_add_ci_move_list(flist, dest_path))
{
file_util_warn_op_in_progress(_("Move failed"));
file_data_disable_grouping_list(ungrouped, FALSE);
- filelist_free(flist);
- filelist_free(ungrouped);
+ file_data_list_free(flist);
return;
}
file_util_mark_ungrouped_files(ungrouped);
- filelist_free(ungrouped);
ud = file_util_data_new(UtilityType::MOVE);
static void file_util_copy_full(FileData *source_fd, GList *flist, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase)
{
UtilityData *ud;
- GList *ungrouped = nullptr;
if (source_fd)
flist = g_list_append(flist, file_data_ref(source_fd));
if (file_util_write_metadata_first(UtilityType::COPY, phase, flist, dest_path, nullptr, parent))
return;
+ g_autoptr(FileDataList) ungrouped = nullptr;
flist = file_data_process_groups_in_selection(flist, TRUE, &ungrouped);
if (!file_data_sc_add_ci_copy_list(flist, dest_path))
{
file_util_warn_op_in_progress(_("Copy failed"));
file_data_disable_grouping_list(ungrouped, FALSE);
- filelist_free(flist);
- filelist_free(ungrouped);
+ file_data_list_free(flist);
return;
}
file_util_mark_ungrouped_files(ungrouped);
- filelist_free(ungrouped);
ud = file_util_data_new(UtilityType::COPY);
static void file_util_rename_full(FileData *source_fd, GList *flist, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase)
{
UtilityData *ud;
- GList *ungrouped = nullptr;
if (source_fd)
flist = g_list_append(flist, file_data_ref(source_fd));
if (!flist) return;
+ g_autoptr(FileDataList) ungrouped = nullptr;
flist = file_data_process_groups_in_selection(flist, TRUE, &ungrouped);
if (!file_data_sc_add_ci_rename_list(flist, dest_path))
{
file_util_warn_op_in_progress(_("Rename failed"));
file_data_disable_grouping_list(ungrouped, FALSE);
- filelist_free(flist);
- filelist_free(ungrouped);
+ file_data_list_free(flist);
return;
}
file_util_mark_ungrouped_files(ungrouped);
- filelist_free(ungrouped);
ud = file_util_data_new(UtilityType::RENAME);
static void file_util_start_editor_full(const gchar *key, FileData *source_fd, GList *flist, const gchar *dest_path, const gchar *working_directory, GtkWidget *parent, UtilityPhase phase)
{
UtilityData *ud;
- GList *ungrouped = nullptr;
if (editor_no_param(key))
{
/* just start the editor, don't care about files */
start_editor(key, working_directory);
- filelist_free(flist);
+ file_data_list_free(flist);
return;
}
if (file_util_write_metadata_first(UtilityType::FILTER, phase, flist, dest_path, key, parent))
return;
+ g_autoptr(FileDataList) ungrouped = nullptr;
flist = file_data_process_groups_in_selection(flist, TRUE, &ungrouped);
if (!file_data_sc_add_ci_unspecified_list(flist, dest_path))
{
file_util_warn_op_in_progress(_("Can't run external editor"));
file_data_disable_grouping_list(ungrouped, FALSE);
- filelist_free(flist);
- filelist_free(ungrouped);
+ file_data_list_free(flist);
return;
}
file_util_mark_ungrouped_files(ungrouped);
- filelist_free(ungrouped);
if (editor_is_filter(key))
ud = file_util_data_new(UtilityType::FILTER);
static gboolean file_util_delete_dir_empty_path(UtilityData *ud, FileData *fd, gint level)
{
- GList *dlist;
- GList *flist;
GList *work;
DEBUG_1("deltree into: %s", fd->path);
{
log_printf("folder recursion depth past %d, giving up\n", UTILITY_DELETE_MAX_DEPTH);
// ud->fail_fd = fd
- return 0;
+ return FALSE;
}
+ g_autoptr(FileDataList) dlist = nullptr;
+ g_autoptr(FileDataList) flist = nullptr;
if (!filelist_read_lstat(fd, &flist, &dlist))
{
// ud->fail_fd = fd
- return 0;
+ return FALSE;
}
gboolean ok = file_data_sc_add_ci_delete(fd);
// ud->fail_fd = fd
}
- filelist_free(dlist);
- filelist_free(flist);
-
DEBUG_1("deltree done: %s", fd->path);
return ok;
}
else
{
- filelist_free(dlist);
+ file_data_list_free(dlist);
file_util_dialog_run(ud);
return;
}
}
g_list_free(rlist);
- filelist_free(dlist);
- filelist_free(flist);
+ file_data_list_free(dlist);
+ file_data_list_free(flist);
}
static gboolean file_util_rename_dir_scan(UtilityData *ud, FileData *fd)
{
- GList *dlist;
+ g_autoptr(FileDataList) dlist = nullptr;
GList *flist;
GList *work;
if (!filelist_read_lstat(fd, &flist, &dlist))
{
// ud->fail_fd = fd
- return 0;
+ return FALSE;
}
ud->content_list = g_list_concat(flist, ud->content_list);
ok = file_util_rename_dir_scan(ud, lfd);
}
- filelist_free(dlist);
-
return ok;
}
}
/* the operation was cancelled */
- filelist_free(dd->flist);
+ file_data_list_free(dd->flist);
g_free(dd->dest_path);
g_free(dd->editor_key);
g_free(dd);
if (fd->change)
{
- filelist_free(unsaved);
+ file_data_list_free(unsaved);
return FALSE; /* another op. in progress, let the caller handle it */
}
path_list_to_clipboard(get_path_list(fd_list), quoted, action, GDK_SELECTION_CLIPBOARD);
}
- filelist_free(fd_list);
+ file_data_list_free(fd_list);
}
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
vd->click_fd = nullptr;
vd->drop_fd = nullptr;
- filelist_free(old_list);
+ file_data_list_free(old_list);
return ret;
}
vd_dnd_drop_scroll_cancel(vd);
widget_auto_scroll_stop(vd->view);
- filelist_free(VDLIST(vd)->list);
+ file_data_list_free(VDLIST(vd)->list);
}
ViewDir *vdlist_new(ViewDir *vd, FileData *)
}
folder_icons_free(vd->pf);
- filelist_free(vd->drop_list);
+ file_data_list_free(vd->drop_list);
file_data_unref(vd->dir_fd);
g_free(vd->info);
vd->popup = nullptr;
vd_color_set(vd, vd->drop_fd, FALSE);
- filelist_free(vd->drop_list);
+ file_data_list_free(vd->drop_list);
vd->drop_list = nullptr;
vd->drop_fd = nullptr;
}
static void vd_pop_menu_dupe(ViewDir *vd, gint recursive)
{
DupeWindow *dw;
- GList *list = nullptr;
if (!vd->click_fd) return;
+ g_autoptr(FileDataList) list = nullptr;
+
if (recursive)
{
list = g_list_append(list, file_data_ref(vd->click_fd));
dw = dupe_window_new();
dupe_window_add_files(dw, list, recursive);
-
- filelist_free(list);
}
static void vd_pop_menu_dupe_cb(GtkWidget *, gpointer data)
void vficon_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode)
{
- GList *slist;
-
g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);
- slist = vficon_selection_get_list(vf);
+ g_autoptr(FileDataList) slist = vficon_selection_get_list(vf);
for (GList *work = slist; work; work = work->next)
{
auto fd = static_cast<FileData *>(work->data);
file_data_selection_to_mark(fd, mark, mode);
}
- filelist_free(slist);
}
static void vficon_select_closest(ViewFile *vf, FileData *sel_fd)
g_list_free(reversed_old_selected);
}
- filelist_free(new_filelist);
+ file_data_list_free(new_filelist);
vficon_populate(vf, TRUE, keep_position);
GtkTreeModel *store;
GtkTreeIter iter;
- filelist_free(list);
+ file_data_list_free(list);
store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
if (vflist_find_row(vf, vf->click_fd, &iter) >= 0)
vflist_select_closest(vf, static_cast<FileData *>(selected->data));
}
- filelist_free(selected);
+ file_data_list_free(selected);
vf_send_update(vf);
vf_thumb_update(vf);
DEBUG_1("%s vflist_refresh: free filelist", get_exec_time());
- filelist_free(old_list);
+ file_data_list_free(old_list);
DEBUG_1("%s vflist_refresh: done", get_exec_time());
return ret;
/* force complete reload */
vflist_store_clear(vf, TRUE);
- filelist_free(vf->list);
+ file_data_list_free(vf->list);
vf->list = nullptr;
ret = vflist_refresh(vf);
vf_thumb_stop(vf);
vf_star_stop(vf);
- filelist_free(vf->list);
+ file_data_list_free(vf->list);
}
ViewFile *vflist_new(ViewFile *vf)
if (!vf->click_fd) return;
- GList *list = nullptr;
+ g_autoptr(FileDataList) list = nullptr;
if (vf_is_selected(vf, vf->click_fd))
{
if (!list) return;
uri_selection_data_set_uris_from_filelist(selection_data, list);
- filelist_free(list);
}
static void vf_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
if (vf_is_selected(vf, vf->click_fd))
{
- GList *list;
-
- list = vf_selection_get_list(vf);
+ g_autoptr(FileDataList) list = vf_selection_get_list(vf);
view_window_new_from_list(list);
- filelist_free(list);
}
else
{
vf->click_fd = nullptr;
vf->popup = nullptr;
- filelist_free(vf->editmenu_fd_list);
+ file_data_list_free(vf->editmenu_fd_list);
vf->editmenu_fd_list = nullptr;
}
* @param[in] widget
* @param[in] data Index to the collection list menu item selected, or -1 for new collection
*
- *
*/
static void vf_pop_menu_collections_cb(GtkWidget *widget, gpointer data)
{
- ViewFile *vf;
- GList *selection_list;
+ auto *vf = static_cast<ViewFile *>(submenu_item_get_data(widget));
- vf = static_cast<ViewFile *>(submenu_item_get_data(widget));
- selection_list = vf_selection_get_list(vf);
+ g_autoptr(FileDataList) selection_list = vf_selection_get_list(vf);
pop_menu_collections(selection_list, data);
-
- filelist_free(selection_list);
}
static void vf_pop_menu_show_star_rating_cb(GtkWidget *, gpointer data)