From: Colin Clark Date: Sat, 21 Aug 2021 10:30:39 +0000 (+0100) Subject: Additional option on cache maintenance page X-Git-Tag: v1.7~72 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=6d362d5c63bb24e418751404202698a43bca1cc4 Additional option on cache maintenance page On the Edit/Cache Maintenance page, include an option to call the cache maintenance command line program. --- diff --git a/doc/docbook/GuideOtherSoftware.xml b/doc/docbook/GuideOtherSoftware.xml index 90647eeb..76130cee 100644 --- a/doc/docbook/GuideOtherSoftware.xml +++ b/doc/docbook/GuideOtherSoftware.xml @@ -17,6 +17,13 @@ https://photini.readthedocs.io/en/latest/ +
+ Unison + + Unison allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other (n.b. there is a GTK GUI .deb package): + https://www.cis.upenn.edu/~bcpierce/unison/ + +
Geeqie Cache Maintenance diff --git a/doc/docbook/GuideReferenceManagement.xml b/doc/docbook/GuideReferenceManagement.xml index 0ca7d2fc..0ce36bcb 100644 --- a/doc/docbook/GuideReferenceManagement.xml +++ b/doc/docbook/GuideReferenceManagement.xml @@ -147,7 +147,6 @@ Metadata located in the folder: $HOME/.local/share/Geeqie/metadata - . @@ -162,10 +161,16 @@
+
+ Background Cache Maintenance + + This facility will run the command line program described below as a stand-alone background job. + +
Command line program - Geeqie can be run as a command line program: geeqie --cache-maintenance <path>. It will recursively remove orphaned thumbnails, and create thumbnails and similarity data for all images found. + Geeqie can be run as a command line program: geeqie --cache-maintenance <path>. It will recursively remove orphaned thumbnails and .sim files, and create thumbnails and similarity data for all images found. It may also be called from cron or anacron thus enabling automatic updating of the cached data for all your images. diff --git a/src/cache_maint.c b/src/cache_maint.c index 04b8bd56..3e96bcb4 100644 --- a/src/cache_maint.c +++ b/src/cache_maint.c @@ -1590,6 +1590,105 @@ static void cache_manager_sim_load_cb(GtkWidget *widget, gpointer data) cache_manager_sim_load_dialog(widget, path); } +static void cache_manager_cache_maintenance_close_cb(GenericDialog *fd, gpointer data) +{ + CacheOpsData *cd = data; + + if (!gtk_widget_get_sensitive(cd->button_close)) return; + + cache_manager_sim_reset(cd); + generic_dialog_close(cd->gd); + g_free(cd); +} + +static void cache_manager_cache_maintenance_start_cb(GenericDialog *fd, gpointer data) +{ + CacheOpsData *cd = data; + gchar *path; + GList *list_total = NULL; + gchar *cmd_line; + + if (!cd->remote) + { + if (cd->list || !gtk_widget_get_sensitive(cd->button_start)) return; + } + + path = remove_trailing_slash((gtk_entry_get_text(GTK_ENTRY(cd->entry)))); + parse_out_relatives(path); + + if (!isdir(path)) + { + if (!cd->remote) + { + warning_dialog(_("Invalid folder"), + _("The specified folder can not be found."), + GTK_STOCK_DIALOG_WARNING, cd->gd->dialog); + } + else + { + log_printf("The specified folder can not be found: %s\n", path); + } + } + else + { + cmd_line = g_strdup_printf("%s --cache-maintenance %s", gq_executable_path, path); + + g_spawn_command_line_async(cmd_line, NULL); + + g_free(cmd_line); + generic_dialog_close(cd->gd); + cache_manager_sim_reset(cd); + g_free(cd); + } + + g_free(path); +} + +static void cache_manager_cache_maintenance_load_dialog(GtkWidget *widget, const gchar *path) +{ + CacheOpsData *cd; + GtkWidget *hbox; + GtkWidget *label; + + cd = g_new0(CacheOpsData, 1); + cd->remote = FALSE; + cd->recurse = TRUE; + + cd->gd = generic_dialog_new(_("Background cache maintenance"), "background_cache_maintenance", widget, FALSE, NULL, cd); + gtk_window_set_default_size(GTK_WINDOW(cd->gd->dialog), PURGE_DIALOG_WIDTH, -1); + cd->gd->cancel_cb = cache_manager_cache_maintenance_close_cb; + cd->button_close = generic_dialog_add_button(cd->gd, GTK_STOCK_CLOSE, NULL, + cache_manager_cache_maintenance_close_cb, FALSE); + cd->button_start = generic_dialog_add_button(cd->gd, GTK_STOCK_OK, _("S_tart"), + cache_manager_cache_maintenance_start_cb, FALSE); + + generic_dialog_add_message(cd->gd, NULL, _("Recursively delete orphaned thumbnails\nand .sim files, and create new\nthumbnails and .sim files"), NULL, FALSE); + + hbox = pref_box_new(cd->gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, 0); + pref_spacer(hbox, PREF_PAD_INDENT); + cd->group = pref_box_new(hbox, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); + + hbox = pref_box_new(cd->group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); + pref_label_new(hbox, _("Folder:")); + + label = tab_completion_new(&cd->entry, path, NULL, NULL, NULL, NULL); + tab_completion_add_select_button(cd->entry,_("Select folder") , TRUE); + gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); + gtk_widget_show(label); + + cd->list = NULL; + + gtk_widget_show(cd->gd->dialog); +} + +static void cache_manager_cache_maintenance_load_cb(GtkWidget *widget, gpointer data) +{ + const gchar *path = layout_get_path(NULL); + + if (!path || !*path) path = homedir(); + cache_manager_cache_maintenance_load_dialog(widget, path); +} + void cache_manager_show(void) { GenericDialog *gd; @@ -1689,6 +1788,16 @@ void cache_manager_show(void) gtk_size_group_add_widget(sizegroup, button); pref_table_label(table, 1, 0, _("Remove orphaned keywords and comments."), 0.0); + group = pref_group_new(gd->vbox, FALSE, _("Background cache maintenance"), GTK_ORIENTATION_VERTICAL); + + table = pref_table_new(group, 3, 2, FALSE, FALSE); + + button = pref_table_button(table, 0, 0, GTK_STOCK_EXECUTE, _("Select"), FALSE, + G_CALLBACK(cache_manager_cache_maintenance_load_cb), cache_manager); + gtk_size_group_add_widget(sizegroup, button); + pref_table_label(table, 1, 0, _("Run cache maintenance as a background job."), 0.0); + gtk_widget_set_sensitive(group, options->thumbnails.enable_caching); + gtk_widget_show(cache_manager->dialog->dialog); } /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/main.c b/src/main.c index 6b19d98e..ce535cb0 100644 --- a/src/main.c +++ b/src/main.c @@ -269,6 +269,7 @@ gchar *gq_helpdir; gchar *gq_htmldir; gchar *gq_app_dir; gchar *gq_bin_dir; +gchar *gq_executable_path; gchar *desktop_file_template; /* @@ -1237,6 +1238,7 @@ static void create_application_paths() exit(1); } + gq_executable_path = g_strdup(buf); dirname = g_path_get_dirname(buf); // default is /usr/bin/ gq_prefix = g_path_get_dirname(dirname); diff --git a/src/main.h b/src/main.h index 87aa96ef..b105cbad 100644 --- a/src/main.h +++ b/src/main.h @@ -151,6 +151,7 @@ extern gchar *gq_helpdir; extern gchar *gq_htmldir; extern gchar *gq_app_dir; extern gchar *gq_bin_dir; +extern gchar *gq_executable_path; extern gchar *desktop_file_template; void keyboard_scroll_calc(gint *x, gint *y, GdkEventKey *event);