/*
- * Geeqie
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2010 The Geeqie Team
+ * Copyright (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
*
* Author: John Ellis
*
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "main.h"
#include "ui_spinner.h"
#include "ui_tabcomp.h"
#include "ui_utildlg.h"
+#include "window.h"
typedef struct _CMData CMData;
*-------------------------------------------------------------------
*/
-#if 0
-static gint extension_truncate(gchar *path, const gchar *ext)
-{
- gint l;
- gint el;
-
- if (!path || !ext) return FALSE;
-
- l = strlen(path);
- el = strlen(ext);
-
- if (l < el || strcmp(path + (l - el), ext) != 0) return FALSE;
-
- path[l - el] = '\0';
-
- return TRUE;
-}
-#endif
-
static gchar *extension_find_dot(gchar *path)
{
gchar *dot = NULL;
{
CMData *cm = data;
-#if GTK_CHECK_VERSION(2,20,0)
if (!gtk_widget_get_sensitive(cm->button_close)) return;
-#else
- if (!GTK_WIDGET_SENSITIVE(cm->button_close)) return;
-#endif
cache_maintain_home_close(cm);
}
gtk_widget_show(hbox);
cm->entry = gtk_entry_new();
- GTK_WIDGET_UNSET_FLAGS(cm->entry, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus(cm->entry, FALSE);
gtk_editable_set_editable(GTK_EDITABLE(cm->entry), FALSE);
gtk_box_pack_start(GTK_BOX(hbox), cm->entry, TRUE, TRUE, 0);
gtk_widget_show(cm->entry);
cm->idle_id = g_idle_add(cache_maintain_home_cb, cm);
}
-#if 0
-/* This checks all files in ~/GQ_RC_DIR/thumbnails and
- * removes them if thay have no source counterpart.
- * (this assumes all cache files have an extension of 4 chars including '.')
- */
-gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear)
-{
- gchar *base;
- gint base_length;
- GList *dlist = NULL;
- FileData *dir_fd;
- GList *flist = NULL;
- gboolean still_have_a_file = FALSE;
-
- DEBUG_1("maintainance check: %s", dir);
-
- base_length = strlen(homedir()) + strlen("/") + strlen(GQ_CACHE_RC_THUMB);
- base = g_strconcat(homedir(), "/", GQ_CACHE_RC_THUMB, dir, NULL);
- dir_fd = file_data_new_dir(base);
- g_free(base);
-
- if (filelist_read(dir_fd, &flist, &dlist))
- {
- GList *work;
-
- work = dlist;
- while (work)
- {
- FileData *fd = work->data;
- if (recursive && strlen(fd->path) > base_length &&
- !cache_maintain_home_dir(fd->path + base_length, recursive, clear))
- {
- DEBUG_1("Deleting thumb dir: %s", fd->path);
- if (!rmdir_utf8(fd->path))
- {
- log_printf("Unable to delete dir: %s\n", fd->path);
- }
- }
- else
- {
- still_have_a_file = TRUE;
- }
- work = work->next;
- }
-
- work = flist;
- while (work)
- {
- FileData *fd = work->data;
- gchar *path = g_strdup(fd->path);
- gchar *dot;
-
- dot = extension_find_dot(path);
-
- if (dot) *dot = '\0';
- if (clear ||
- (strlen(path) > base_length && !isfile(path + base_length)) )
- {
- if (dot) *dot = '.';
- if (!unlink_file(path)) log_printf("failed to delete:%s\n", path);
- }
- else
- {
- still_have_a_file = TRUE;
- }
- g_free(path);
-
- work = work->next;
- }
- }
-
- filelist_free(dlist);
- filelist_free(flist);
- file_data_unref(dir_fd);
-
- return still_have_a_file;
-}
-
-/* This checks relative caches in dir/.thumbnails and
- * removes them if they have no source counterpart.
- */
-gint cache_maintain_dir(FileData *dir_fd, gint recursive, gint clear)
-{
- GList *list = NULL;
- gchar *cachedir;
- FileData *cachedir_fd;
- gboolean still_have_a_file = FALSE;
- GList *work;
-
- cachedir = g_build_filename(dir, GQ_CACHE_LOCAL_THUMB, NULL);
- cachedir_fd = file_data_new_dir(cachedir);
- g_free(cachedir);
-
- filelist_read(cachedir_fd, &list, NULL);
- work = list;
-
- while (work)
- {
- FileData *fd;
- gchar *source;
-
- fd = work->data;
- work = work->next;
-
- source = g_build_filename(dir->path, fd->name, NULL);
-
- if (clear ||
- extension_truncate(source, GQ_CACHE_EXT_THUMB) ||
- extension_truncate(source, GQ_CACHE_EXT_SIM))
- {
- if (!clear && isfile(source))
- {
- still_have_a_file = TRUE;
- }
- else
- {
- if (!unlink_file(fd->path))
- {
- DEBUG_1("Failed to remove cache file %s", fd->path);
- still_have_a_file = TRUE;
- }
- }
- }
- else
- {
- still_have_a_file = TRUE;
- }
- g_free(source);
- }
-
- filelist_free(list);
- file_data_unref(cachedir_fd);
-
- if (recursive)
- {
- list = NULL;
-
- filelist_read(dir_fd, NULL, &list);
- work = list;
- while (work)
- {
- FileData *fd = work->data;
- work = work->next;
-
- still_have_a_file |= cache_maintain_dir(fd->path, recursive, clear);
- }
-
- filelist_free(list);
- }
-
- return still_have_a_file;
-}
-#endif
-
static void cache_file_move(const gchar *src, const gchar *dest)
{
if (!dest || !src || !isfile(src)) return;
void cache_notify_cb(FileData *fd, NotifyType type, gpointer data)
{
if (!(type & NOTIFY_CHANGE) || !fd->change) return;
-
+
DEBUG_1("Notify cache_maint: %s %04x", fd->path, type);
switch (fd->change->type)
{
{
CleanData *cd = data;
-#if GTK_CHECK_VERSION(2,20,0)
if (!gtk_widget_get_sensitive(cd->button_close)) return;
-#else
- if (!GTK_WIDGET_SENSITIVE(cd->button_close)) return;
-#endif
cache_manager_render_reset(cd);
generic_dialog_close(cd->gd);
CleanData *cd = data;
gchar *path;
-#if GTK_CHECK_VERSION(2,20,0)
if (cd->list || !gtk_widget_get_sensitive(cd->button_start)) return;
-#else
- if (cd->list || !GTK_WIDGET_SENSITIVE(cd->button_start)) return;
-#endif
path = remove_trailing_slash((gtk_entry_get_text(GTK_ENTRY(cd->entry))));
parse_out_relatives(path);
hbox = pref_box_new(cd->gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
cd->progress = gtk_entry_new();
- GTK_WIDGET_UNSET_FLAGS(cd->progress, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus(cd->progress, FALSE);
gtk_editable_set_editable(GTK_EDITABLE(cd->progress), FALSE);
gtk_entry_set_text(GTK_ENTRY(cd->progress), _("click start to begin"));
gtk_box_pack_start(GTK_BOX(hbox), cd->progress, TRUE, TRUE, 0);
{
CleanData *cd = data;
-#if GTK_CHECK_VERSION(2,20,0)
if (!gtk_widget_get_sensitive(cd->button_close)) return;
-#else
- if (!GTK_WIDGET_SENSITIVE(cd->button_close)) return;
-#endif
generic_dialog_close(cd->gd);
gchar *path;
FileData *dir_fd;
-#if GTK_CHECK_VERSION(2,20,0)
if (cd->list || !gtk_widget_get_sensitive(cd->button_start)) return;
-#else
- if (cd->list || !GTK_WIDGET_SENSITIVE(cd->button_start)) return;
-#endif
gtk_widget_set_sensitive(cd->button_start, FALSE);
gtk_widget_set_sensitive(cd->button_stop, TRUE);
cd->progress = gtk_progress_bar_new();
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("click start to begin"));
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(cd->progress), TRUE);
+#endif
gtk_box_pack_start(GTK_BOX(cd->gd->vbox), cd->progress, FALSE, FALSE, 0);
gtk_widget_show(cd->progress);
cache_manager = NULL;
}
+static void cache_manager_help_cb(GenericDialog *gd, gpointer data)
+{
+ help_window_show("GuideReferenceManagement.html");
+}
+
static GtkWidget *cache_manager_location_label(GtkWidget *group, const gchar *subdir)
{
GtkWidget *label;
gchar *buf;
- gchar *path;
- path = g_build_filename(homedir(), subdir, NULL);
- buf = g_strdup_printf(_("Location: %s"), path);
- g_free(path);
+ buf = g_strdup_printf(_("Location: %s"), subdir);
label = pref_label_new(group, buf);
g_free(buf);
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-
+
return label;
}
GtkWidget *button;
GtkWidget *table;
GtkSizeGroup *sizegroup;
+ gchar *path;
if (cache_manager)
{
gd->cancel_cb = cache_manager_close_cb;
generic_dialog_add_button(gd, GTK_STOCK_CLOSE, NULL,
cache_manager_close_cb, FALSE);
+ generic_dialog_add_button(gd, GTK_STOCK_HELP, NULL,
+ cache_manager_help_cb, FALSE);
generic_dialog_add_message(gd, NULL, _("Cache and Data Maintenance"), NULL);
group = pref_group_new(gd->vbox, FALSE, _("Shared thumbnail cache"), GTK_ORIENTATION_VERTICAL);
- cache_manager_location_label(group, THUMB_FOLDER_GLOBAL);
+ path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, NULL);
+ cache_manager_location_label(group, path);
+ g_free(path);
table = pref_table_new(group, 2, 2, FALSE, FALSE);