dupe_window_add_folder(folder_path);
}
+void gq_dupes_export(GtkApplication *, GApplicationCommandLine *app_command_line, GVariantDict *, GList *)
+{
+ g_autoptr(GString) output_string = g_string_new(nullptr);
+
+ export_duplicates_data_command_line(output_string);
+
+ g_application_command_line_print(app_command_line, "%s\n", output_string->str);
+}
+
void gq_dupes_recurse(GtkApplication *app, GApplicationCommandLine *app_command_line, GVariantDict *command_line_options_dict, GList *)
{
const gchar *path;
{ "delay", gq_delay, PRIMARY_REMOTE, GUI },
{ "file", gq_file, PRIMARY_REMOTE, GUI },
{ "dupes", gq_dupes, PRIMARY_REMOTE, GUI },
+ { "dupes-export", gq_dupes_export, PRIMARY_REMOTE, TEXT },
{ "dupes-recurse", gq_dupes_recurse, PRIMARY_REMOTE, GUI },
{ "File", gq_File, PRIMARY_REMOTE, GUI },
{ "file-extensions", gq_file_extensions, PRIMARY_REMOTE, TEXT },
export_duplicates_close(edd);
}
-static void export_duplicates_data_save_cb(FileDialog *fdlg, gpointer data)
+static void export_duplicates_data(DupeWindow *dw, const gchar *sep, GString *output_string)
{
- auto edd = static_cast<ExportDupesData *>(data);
GtkTreeModel *store;
GtkTreeIter iter;
DupeItem *di;
- GFileOutputStream *gfstream;
- GFile *out_file;
GList *work;
GtkTreeSelection *selection;
GList *slist;
gboolean color_new = FALSE;
gint match_count;
- history_list_add_to_key("export_duplicates", fdlg->dest_path, -1);
-
- out_file = g_file_new_for_path(fdlg->dest_path);
-
- g_autoptr(GError) error = nullptr;
- gfstream = g_file_replace(out_file, nullptr, TRUE, G_FILE_CREATE_NONE, nullptr, &error);
- if (error)
- {
- log_printf(_("Error creating Export duplicates data file: Error: %s\n"), error->message);
- return;
- }
-
- const gchar *sep = (edd->separator == EXPORT_CSV) ? "," : "\t";
g_autofree gchar *header = g_strjoin(sep, _("Match"), _("Group"), _("Similarity"), _("Set"), _("Thumbnail"), _("Name"), _("Size"), _("Date"), _("Width"), _("Height"), _("Path"), NULL);
- g_autoptr(GString) output_string = g_string_new(header);
+ output_string = g_string_append(output_string, header);
output_string = g_string_append_c(output_string, '\n');
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(edd->dupewindow->listview));
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dw->listview));
+ gtk_tree_selection_select_all(selection);
slist = gtk_tree_selection_get_selected_rows(selection, &store);
work = slist;
g_string_append_printf(output_string, "%d", match_count);
output_string = g_string_append(output_string, sep);
- if ((dupe_match_find_parent(edd->dupewindow, di) == di))
+ if ((dupe_match_find_parent(dw, di) == di))
{
output_string = g_string_append(output_string, "1");
}
work = work->next;
}
g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
+}
+
+static void export_duplicates_data_save_cb(FileDialog *fdlg, gpointer data)
+{
+ auto edd = static_cast<ExportDupesData *>(data);
+ GFileOutputStream *gfstream;
+ GFile *out_file;
+
+ history_list_add_to_key("export_duplicates", fdlg->dest_path, -1);
+
+ out_file = g_file_new_for_path(fdlg->dest_path);
+
+ g_autoptr(GError) error = nullptr;
+ gfstream = g_file_replace(out_file, nullptr, TRUE, G_FILE_CREATE_NONE, nullptr, &error);
+ if (error)
+ {
+ log_printf(_("Error creating Export duplicates data file: Error: %s\n"), error->message);
+ return;
+ }
+
+ const gchar *sep = (edd->separator == EXPORT_CSV) ? "," : "\t";
+
+ g_autoptr(GString) output_string = g_string_new(nullptr);
+
+ export_duplicates_data((edd->dupewindow), sep, output_string);
g_output_stream_write(G_OUTPUT_STREAM(gfstream), output_string->str, output_string->len, nullptr, &error);
export_duplicates_close(edd);
}
+void export_duplicates_data_command_line(GString *output_string)
+{
+ if (dupe_window_list != nullptr)
+ {
+ auto dw = static_cast<DupeWindow *>(g_list_last(dupe_window_list)->data);
+
+ if (dw->idle_id != 0)
+ {
+ output_string = g_string_append(output_string, _("Incomplete"));
+ }
+ else
+ {
+ export_duplicates_data(dw, "\t", output_string);
+ }
+ }
+ else
+ {
+ output_string = g_string_append(output_string, _("No duplicates windows open"));
+ }
+}
+
static void pop_menu_export(GList *, gpointer dupe_window, gpointer data)
{
const gint index = GPOINTER_TO_INT(data);
#endif
{ "delay" , 'd', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, nullptr, _("set slide show delay to Hrs Mins N.M seconds,") , "<[H:][M:][N][.M]>" },
{ "dupes" , 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, nullptr, _("find duplicates in folder") , "<FOLDER>" },
+ { "dupes-export" , 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, nullptr, _("export duplicates search result") , nullptr },
{ "dupes-recurse" , 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, nullptr, _("find duplicates in folder recursively") , "<FOLDER>" },
{ "file" , 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, nullptr, _("open FILE or URL bring Geeqie window to the top") , "<FILE>|<URL>" },
{ "File" , 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, nullptr, _("open FILE or URL do not bring Geeqie window to the top") , "<FILE>|<URL>" },