* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "dupe.h"
+
+#include <sys/time.h>
+#include <sys/types.h>
+
#include <cinttypes>
+#include <cmath>
+#include <cstdlib>
+#include <cstring>
-#include "main.h"
-#include "dupe.h"
+#include <gdk/gdk.h>
+#include <gio/gio.h>
+#include <glib-object.h>
#include "cache.h"
#include "collect-table.h"
+#include "collect.h"
+#include "compat.h"
+#include "debug.h"
#include "dnd.h"
#include "filedata.h"
#include "history-list.h"
#include "image-load.h"
#include "img-view.h"
+#include "intl.h"
#include "layout-image.h"
#include "layout-util.h"
+#include "layout.h"
+#include "main-defines.h"
#include "md5-util.h"
#include "menu.h"
#include "misc.h"
-#include "pixbuf-util.h"
+#include "options.h"
#include "print.h"
+#include "similar.h"
#include "thumb.h"
+#include "typedefs.h"
#include "ui-fileops.h"
#include "ui-menu.h"
#include "ui-misc.h"
#include "ui-tree-edit.h"
+#include "ui-utildlg.h"
#include "uri-utils.h"
#include "utilops.h"
#include "window.h"
-#include <cmath>
-
-
-#define DUPE_DEF_WIDTH 800
-#define DUPE_DEF_HEIGHT 400
+enum {
+ DUPE_DEF_WIDTH = 800,
+ DUPE_DEF_HEIGHT = 400
+};
#define DUPE_PROGRESS_PULSE_STEP 0.0001
/** column assignment order (simply change them here)
d = dw->setup_count - dw->setup_n;
}
- rem = (t - d) ? (static_cast<gdouble>(dw->setup_time_count / 1000000) / (t - d)) * d : 0;
+ rem = (t - d) ? (static_cast<gdouble>(dw->setup_time_count / 1000000.0) / (t - d)) * d : 0;
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(dw->extra_label), value);
return;
}
- else if (force ||
+
+ if (force ||
value == 0.0 ||
dw->setup_count == 0 ||
dw->setup_time_count == 0 ||
{
while (work)
{
- DupeItem *di = static_cast<DupeItem *>(work->data);
+ auto *di = static_cast<DupeItem *>(work->data);
if (di->fd == fd) return di;
work = work->next;
}
- return NULL;
+ return nullptr;
}
static DupeItem *dupe_item_find_fd_unused(DupeWindow *dw, FileData *fd)
{
while (work)
{
- DupeItem *di = static_cast<DupeItem *>(work->data);
+ auto *di = static_cast<DupeItem *>(work->data);
if (strcmp(di->fd->path, path) == 0) return di;
work = work->next;
}
- return NULL;
+ return nullptr;
}
static DupeItem *dupe_item_find_path_unused(DupeWindow *dw, const gchar *path)
{
return TRUE;
}
- else
- {
- return FALSE;
- }
- }
- else
- {
+
return FALSE;
}
+ return FALSE;
}
if (mask & DUPE_MATCH_NAME_CI_CONTENT)
{
{
return TRUE;
}
- else
- {
- return FALSE;
- }
- }
- else
- {
+
return FALSE;
}
+ return FALSE;
+
}
if (mask & DUPE_MATCH_SIZE)
{
{
return -1;
}
- else
- {
- return strcmp(di1->md5sum, di2->md5sum);
- }
+
+ return strcmp(di1->md5sum, di2->md5sum);
}
if (mask & DUPE_MATCH_DIM)
{
{
auto dw = static_cast<DupeWindow *>(data);
DupeSearchMatch *search_match_list_item;
+ gchar *progress_text;
if (!dw->idle_id)
{
{
if( dw->thread_count < dw->queue_count)
{
- dupe_window_update_progress(dw, _("Comparing..."), 0.0, FALSE);
+ progress_text = g_strdup_printf("%s %d%s%d", _("Comparing"), dw->thread_count, "/", dw->queue_count);
+
+ dupe_window_update_progress(dw, progress_text, (gdouble)dw->thread_count / dw->queue_count, TRUE);
+
+ g_free(progress_text);
return G_SOURCE_CONTINUE;
}
}
else if (isdir(fd->path))
{
- GList *f, *d;
+ GList *f;
+ GList *d;
dw->add_files_queue = g_list_remove(dw->add_files_queue, g_list_first(dw->add_files_queue)->data);
if (filelist_read(fd, &f, &d))
{
return TRUE;
}
- else
- {
- dw->add_files_queue_id = 0;
- dupe_destroy_list_cache(dw);
- g_idle_add(dupe_check_start_cb, dw);
- gtk_widget_set_sensitive(dw->controls_box, TRUE);
- return FALSE;
- }
+
+ dw->add_files_queue_id = 0;
+ dupe_destroy_list_cache(dw);
+ g_idle_add(dupe_check_start_cb, dw);
+ gtk_widget_set_sensitive(dw->controls_box, TRUE);
+ return FALSE;
}
static void dupe_files_add(DupeWindow *dw, CollectionData *, CollectInfo *info,
}
else if (isdir(fd->path) && recurse)
{
- GList *f, *d;
+ GList *f;
+ GList *d;
if (filelist_read(fd, &f, &d))
{
GList *work;
{
return;
}
- else
- {
- work = work->next;
- }
+
+ work = work->next;
}
if (dw->second_list)
{
return;
}
- else
- {
- work = work->next;
- }
+
+ work = work->next;
}
}
work = work->next;
if (isdir(fd->path) && !recurse)
{
- GList *f, *d;
+ GList *f;
+ GList *d;
if (filelist_read(fd, &f, &d))
{
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
label = gtk_label_new(description);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
gtk_widget_show(label);
label = gtk_label_new(text);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
gtk_widget_show(label);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show(hbox);
return label;
if (!di) return;
- gd = file_util_gen_dlg("Image thumbprint debug info", "thumbprint",
+ gd = file_util_gen_dlg(_("Image thumbprint debug info"), "thumbprint",
dw->window, TRUE,
nullptr, nullptr);
generic_dialog_add_button(gd, GQ_ICON_CLOSE, _("Close"), nullptr, TRUE);
{
GtkWidget *image;
GdkPixbuf *pixbuf;
- gint x, y;
+ gint x;
+ gint y;
guchar *d_pix;
guchar *dp;
gint rs;
}
image = gtk_image_new_from_pixbuf(pixbuf);
- gtk_box_pack_start(GTK_BOX(gd->vbox), image, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(gd->vbox), image, FALSE, FALSE, 0);
gtk_widget_show(image);
g_object_unref(pixbuf);
if (dw->second_set)
{
dupe_second_update_status(dw);
- gtk_table_set_col_spacings(GTK_TABLE(dw->table), PREF_PAD_GAP);
+ gtk_grid_set_column_spacing(GTK_GRID(dw->table), PREF_PAD_GAP);
gtk_widget_show(dw->second_vbox);
}
else
{
- gtk_table_set_col_spacings(GTK_TABLE(dw->table), 0);
+ gtk_grid_set_column_spacing(GTK_GRID(dw->table), 0);
gtk_widget_hide(dw->second_vbox);
dupe_second_clear(dw);
}
/* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */
-#define CELL_HEIGHT_OVERRIDE 512
+enum {
+ CELL_HEIGHT_OVERRIDE = 512
+};
void cell_renderer_height_override(GtkCellRenderer *renderer)
{
}
}
-static GdkColor *dupe_listview_color_shifted(GtkWidget *widget)
+static GdkRGBA *dupe_listview_color_shifted(GtkWidget *widget)
{
- static GdkColor color;
+ static GdkRGBA color;
static GtkWidget *done = nullptr;
if (done != widget)
GtkStyle *style;
style = gtk_widget_get_style(widget);
- memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color));
+ convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_NORMAL], &color);
+
shift_color(&color, -1, 0);
done = widget;
}
gtk_tree_model_get(tree_model, iter, DUPE_COLUMN_COLOR, &set, -1);
g_object_set(G_OBJECT(cell),
- "cell-background-gdk", dupe_listview_color_shifted(dw->listview),
+ "cell-background-rgba", dupe_listview_color_shifted(dw->listview),
"cell-background-set", set, NULL);
}
}
}
}
+ else if (event->state & GDK_SHIFT_MASK)
+ {
+ stop_signal = TRUE;
+ switch (event->keyval)
+ {
+ case GDK_KEY_Delete:
+ case GDK_KEY_KP_Delete:
+ options->file_ops.safe_delete_enable = FALSE;
+ file_util_delete_notify_done(nullptr, dupe_listview_get_selection(dw, dw->listview), dw->window, delete_finished_cb, dw);
+ break;
+ default:
+ stop_signal = FALSE;
+ break;
+ }
+ }
else
{
stop_signal = TRUE;
dupe_window_get_geometry(dw);
dupe_window_list = g_list_remove(dupe_window_list, dw);
- gtk_widget_destroy(dw->window);
+ gq_gtk_widget_destroy(dw->window);
g_list_free(dw->dupes);
g_list_free_full(dw->list, reinterpret_cast<GDestroyNotify>(dupe_item_free));
{
auto sortable = static_cast<GtkTreeSortable *>(data);
gint ret = 0;
- gchar *rank_str_a, *rank_str_b;
+ gchar *rank_str_a;
+ gchar *rank_str_b;
gint rank_int_a;
gint rank_int_b;
gint group_a;
if (options->duplicates_match == DUPE_MATCH_NAME_CI_CONTENT) dw->match_mask = DUPE_MATCH_NAME_CI_CONTENT;
if (options->duplicates_match == DUPE_MATCH_ALL) dw->match_mask = DUPE_MATCH_ALL;
- dw->window = window_new(GTK_WINDOW_TOPLEVEL, "dupe", nullptr, nullptr, _("Find duplicates"));
+ dw->window = window_new("dupe", nullptr, nullptr, _("Find duplicates"));
DEBUG_NAME(dw->window);
geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
if (lw && options->save_window_positions)
{
gtk_window_set_default_size(GTK_WINDOW(dw->window), lw->options.dupe_window.w, lw->options.dupe_window.h);
- gtk_window_move(GTK_WINDOW(dw->window), lw->options.dupe_window.x, lw->options.dupe_window.y);
+ gq_gtk_window_move(GTK_WINDOW(dw->window), lw->options.dupe_window.x, lw->options.dupe_window.y);
}
else
{
G_CALLBACK(dupe_window_keypress_cb), dw);
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add(GTK_CONTAINER(dw->window), vbox);
+ gq_gtk_container_add(GTK_WIDGET(dw->window), vbox);
gtk_widget_show(vbox);
- dw->table = gtk_table_new(1, 3, FALSE);
- gtk_box_pack_start(GTK_BOX(vbox), dw->table, TRUE, TRUE, 0);
+ dw->table = gtk_grid_new();
+ gq_gtk_box_pack_start(GTK_BOX(vbox), dw->table, TRUE, TRUE, 0);
+ gtk_grid_set_row_homogeneous(GTK_GRID(dw->table), TRUE);
+ gtk_grid_set_column_homogeneous(GTK_GRID(dw->table), TRUE);
gtk_widget_show(dw->table);
- scrolled = gtk_scrolled_window_new(nullptr, nullptr);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
+ scrolled = gq_gtk_scrolled_window_new(nullptr, nullptr);
+ gq_gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_table_attach_defaults(GTK_TABLE(dw->table), scrolled, 0, 2, 0, 1);
+ gtk_grid_attach(GTK_GRID(dw->table), scrolled, 0, 0, 2, 1);
gtk_widget_show(scrolled);
store = gtk_list_store_new(DUPE_COLUMN_COUNT, G_TYPE_POINTER, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_INT);
g_signal_connect(gtk_tree_view_get_column(GTK_TREE_VIEW(dw->listview), DUPE_COLUMN_DIMENSIONS - 1), "clicked", (GCallback)column_clicked_cb, dw);
g_signal_connect(gtk_tree_view_get_column(GTK_TREE_VIEW(dw->listview), DUPE_COLUMN_PATH - 1), "clicked", (GCallback)column_clicked_cb, dw);
- gtk_container_add(GTK_CONTAINER(scrolled), dw->listview);
+ gq_gtk_container_add(GTK_WIDGET(scrolled), dw->listview);
gtk_widget_show(dw->listview);
dw->second_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_table_attach_defaults(GTK_TABLE(dw->table), dw->second_vbox, 2, 3, 0, 1);
+ gtk_grid_attach(GTK_GRID(dw->table), dw->second_vbox, 2, 0, 3, 1);
if (dw->second_set)
{
- gtk_table_set_col_spacings(GTK_TABLE(dw->table), PREF_PAD_GAP);
+ gtk_grid_set_column_spacing(GTK_GRID(dw->table), PREF_PAD_GAP);
gtk_widget_show(dw->second_vbox);
}
else
{
- gtk_table_set_col_spacings(GTK_TABLE(dw->table), 0);
+ gtk_grid_set_column_spacing(GTK_GRID(dw->table), 0);
}
- scrolled = gtk_scrolled_window_new(nullptr, nullptr);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
+ scrolled = gq_gtk_scrolled_window_new(nullptr, nullptr);
+ gq_gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start(GTK_BOX(dw->second_vbox), scrolled, TRUE, TRUE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(dw->second_vbox), scrolled, TRUE, TRUE, 0);
gtk_widget_show(scrolled);
store = gtk_list_store_new(2, G_TYPE_POINTER, G_TYPE_STRING);
dupe_listview_add_column(dw, dw->second_listview, 1, _("Compare to:"), FALSE, FALSE);
- gtk_container_add(GTK_CONTAINER(scrolled), dw->second_listview);
+ gq_gtk_container_add(GTK_WIDGET(scrolled), dw->second_listview);
gtk_widget_show(dw->second_listview);
dw->second_status_label = gtk_label_new("");
- gtk_box_pack_start(GTK_BOX(dw->second_vbox), dw->second_status_label, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(dw->second_vbox), dw->second_status_label, FALSE, FALSE, 0);
gtk_widget_show(dw->second_status_label);
pref_line(dw->second_vbox, GTK_ORIENTATION_HORIZONTAL);
status_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start(GTK_BOX(vbox), status_box, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(vbox), status_box, FALSE, FALSE, 0);
gtk_widget_show(status_box);
frame = gtk_frame_new(nullptr);
DEBUG_NAME(frame);
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
- gtk_box_pack_start(GTK_BOX(status_box), frame, TRUE, TRUE, 0);
+ gq_gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
+ gq_gtk_box_pack_start(GTK_BOX(status_box), frame, TRUE, TRUE, 0);
gtk_widget_show(frame);
dw->status_label = gtk_label_new("");
- gtk_container_add(GTK_CONTAINER(frame), dw->status_label);
+ gq_gtk_container_add(GTK_WIDGET(frame), dw->status_label);
gtk_widget_show(dw->status_label);
dw->extra_label = gtk_progress_bar_new();
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(dw->extra_label), 0.0);
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(dw->extra_label), "");
gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(dw->extra_label), TRUE);
- gtk_box_pack_start(GTK_BOX(status_box), dw->extra_label, FALSE, FALSE, PREF_PAD_SPACE);
+ gq_gtk_box_pack_start(GTK_BOX(status_box), dw->extra_label, FALSE, FALSE, PREF_PAD_SPACE);
gtk_widget_show(dw->extra_label);
controls_box = pref_box_new(vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, 0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dw->button_thumbs), dw->show_thumbs);
g_signal_connect(G_OBJECT(dw->button_thumbs), "toggled",
G_CALLBACK(dupe_window_show_thumb_cb), dw);
- gtk_box_pack_start(GTK_BOX(controls_box), dw->button_thumbs, FALSE, FALSE, PREF_PAD_SPACE);
+ gq_gtk_box_pack_start(GTK_BOX(controls_box), dw->button_thumbs, FALSE, FALSE, PREF_PAD_SPACE);
gtk_widget_show(dw->button_thumbs);
label = gtk_label_new(_("Compare by:"));
- gtk_box_pack_start(GTK_BOX(controls_box), label, FALSE, FALSE, PREF_PAD_SPACE);
+ gq_gtk_box_pack_start(GTK_BOX(controls_box), label, FALSE, FALSE, PREF_PAD_SPACE);
gtk_widget_show(label);
dupe_menu_setup(dw);
- gtk_box_pack_start(GTK_BOX(controls_box), dw->combo, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(controls_box), dw->combo, FALSE, FALSE, 0);
gtk_widget_show(dw->combo);
label = gtk_label_new(_("Custom Threshold"));
- gtk_box_pack_start(GTK_BOX(controls_box), label, FALSE, FALSE, PREF_PAD_SPACE);
+ gq_gtk_box_pack_start(GTK_BOX(controls_box), label, FALSE, FALSE, PREF_PAD_SPACE);
gtk_widget_show(label);
dw->custom_threshold = gtk_spin_button_new_with_range(1, 100, 1);
gtk_widget_set_tooltip_text(GTK_WIDGET(dw->custom_threshold), "Custom similarity threshold\n(Use tab key to set value)");
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dw->custom_threshold), options->duplicates_similarity_threshold);
g_signal_connect(G_OBJECT(dw->custom_threshold), "value_changed", G_CALLBACK(dupe_window_custom_threshold_cb), dw);
- gtk_box_pack_start(GTK_BOX(controls_box), dw->custom_threshold, FALSE, FALSE, PREF_PAD_SPACE);
+ gq_gtk_box_pack_start(GTK_BOX(controls_box), dw->custom_threshold, FALSE, FALSE, PREF_PAD_SPACE);
gtk_widget_show(dw->custom_threshold);
button = gtk_check_button_new_with_label(_("Sort"));
- gtk_widget_set_tooltip_text(GTK_WIDGET(button), "Sort by group totals");
+ gtk_widget_set_tooltip_text(GTK_WIDGET(button), _("Sort by group totals"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), options->sort_totals);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(dupe_sort_totals_toggle_cb), dw);
- gtk_box_pack_start(GTK_BOX(controls_box), button, FALSE, FALSE, PREF_PAD_SPACE);
+ gq_gtk_box_pack_start(GTK_BOX(controls_box), button, FALSE, FALSE, PREF_PAD_SPACE);
gtk_widget_show(button);
dw->button_rotation_invariant = gtk_check_button_new_with_label(_("Ignore Orientation"));
- gtk_widget_set_tooltip_text(GTK_WIDGET(dw->button_rotation_invariant), "Ignore image orientation");
+ gtk_widget_set_tooltip_text(GTK_WIDGET(dw->button_rotation_invariant), _("Ignore image orientation"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dw->button_rotation_invariant), options->rot_invariant_sim);
g_signal_connect(G_OBJECT(dw->button_rotation_invariant), "toggled",
G_CALLBACK(dupe_window_rotation_invariant_cb), dw);
- gtk_box_pack_start(GTK_BOX(controls_box), dw->button_rotation_invariant, FALSE, FALSE, PREF_PAD_SPACE);
+ gq_gtk_box_pack_start(GTK_BOX(controls_box), dw->button_rotation_invariant, FALSE, FALSE, PREF_PAD_SPACE);
gtk_widget_show(dw->button_rotation_invariant);
button = gtk_check_button_new_with_label(_("Compare two file sets"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), dw->second_set);
g_signal_connect(G_OBJECT(button), "toggled",
G_CALLBACK(dupe_second_set_toggle_cb), dw);
- gtk_box_pack_start(GTK_BOX(controls_box), button, FALSE, FALSE, PREF_PAD_SPACE);
+ gq_gtk_box_pack_start(GTK_BOX(controls_box), button, FALSE, FALSE, PREF_PAD_SPACE);
gtk_widget_show(button);
button_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start(GTK_BOX(vbox), button_box, FALSE, FALSE, 0);
+ gq_gtk_box_pack_start(GTK_BOX(vbox), button_box, FALSE, FALSE, 0);
gtk_widget_show(button_box);
hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
gtk_box_set_spacing(GTK_BOX(hbox), PREF_PAD_SPACE);
- gtk_box_pack_end(GTK_BOX(button_box), hbox, FALSE, FALSE, 0);
+ gq_gtk_box_pack_end(GTK_BOX(button_box), hbox, FALSE, FALSE, 0);
gtk_widget_show(hbox);
button = pref_button_new(nullptr, GQ_ICON_HELP, _("Help"), G_CALLBACK(dupe_help_cb), nullptr);
gtk_widget_set_tooltip_text(GTK_WIDGET(button), "F1");
- gtk_container_add(GTK_CONTAINER(hbox), button);
+ gq_gtk_container_add(GTK_WIDGET(hbox), button);
gtk_widget_set_can_default(button, TRUE);
gtk_widget_show(button);
button = pref_button_new(nullptr, GQ_ICON_STOP, _("Stop"), G_CALLBACK(dupe_check_stop_cb), dw);
- gtk_container_add(GTK_CONTAINER(hbox), button);
+ gq_gtk_container_add(GTK_WIDGET(hbox), button);
gtk_widget_set_can_default(button, TRUE);
gtk_widget_show(button);
button = pref_button_new(nullptr, GQ_ICON_CLOSE, _("Close"), G_CALLBACK(dupe_window_close_cb), dw);
gtk_widget_set_tooltip_text(GTK_WIDGET(button), "Ctrl-W");
- gtk_container_add(GTK_CONTAINER(hbox), button);
+ gq_gtk_container_add(GTK_WIDGET(hbox), button);
gtk_widget_set_can_default(button, TRUE);
gtk_widget_grab_default(button);
gtk_widget_show(button);
GFileOutputStream *gfstream;
GFile *out_file;
GString *output_string;
- gchar *sep;
gchar* rank;
GList *work;
GtkTreeSelection *selection;
return;
}
- sep = g_strdup((edd->separator == EXPORT_CSV) ? "," : "\t");
+ const gchar *sep = (edd->separator == EXPORT_CSV) ? "," : "\t";
output_string = g_string_new(g_strjoin(sep, _("Match"), _("Group"), _("Similarity"), _("Set"), _("Thumbnail"), _("Name"), _("Size"), _("Date"), _("Width"), _("Height"), _("Path\n"), NULL));
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(edd->dupewindow->listview));
match_count++;
}
color_old = color_new;
- output_string = g_string_append(output_string, g_strdup_printf("%d", match_count));
+ 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))
}
else
{
- output_string = g_string_append(output_string, g_strdup_printf("%s", rank_split[0]));
+ output_string = g_string_append(output_string, rank_split[0]);
}
output_string = g_string_append(output_string, sep);
g_free(rank);
g_strfreev(rank_split);
- output_string = g_string_append(output_string, g_strdup_printf("%d", (di->second + 1)));
+ g_string_append_printf(output_string, "%d", di->second + 1);
output_string = g_string_append(output_string, sep);
thumb_cache = cache_find_location(CACHE_TYPE_THUMB, di->fd->path);
output_string = g_string_append(output_string, sep);
g_free(name);
- output_string = g_string_append(output_string, g_strdup_printf("%" PRIu64, di->fd->size));
+ g_string_append_printf(output_string, "%" PRIu64, di->fd->size);
output_string = g_string_append(output_string, sep);
output_string = g_string_append(output_string, text_from_time(di->fd->date));
output_string = g_string_append(output_string, sep);
- output_string = g_string_append(output_string, g_strdup_printf("%d", (di->width ? di->width : 0)));
+ g_string_append_printf(output_string, "%d", di->width);
output_string = g_string_append(output_string, sep);
- output_string = g_string_append(output_string, g_strdup_printf("%d", (di->height ? di->height : 0)));
+ g_string_append_printf(output_string, "%d", di->height);
output_string = g_string_append(output_string, sep);
output_string = g_string_append(output_string, di->fd->path);
output_string = g_string_append_c(output_string, '\n');
work = work->next;
}
- g_output_stream_write(G_OUTPUT_STREAM(gfstream), output_string->str, strlen(output_string->str), nullptr, &error);
+ g_output_stream_write(G_OUTPUT_STREAM(gfstream), output_string->str, output_string->len, nullptr, &error);
- g_free(sep);
g_string_free(output_string, TRUE);
g_object_unref(gfstream);
g_object_unref(out_file);
{
const gint index = GPOINTER_TO_INT(data);
auto dw = static_cast<DupeWindow *>(dupe_window);
- const gchar *title = "Export duplicates data";
+ const gchar *title = _("Export duplicates data");
const gchar *default_path = "/tmp/";
gchar *file_extension;
ExportDupesData *edd;