Skip to content

Commit

Permalink
used new notification in cache_maint
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik committed Jun 6, 2008
1 parent f335345 commit dd62fe1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
28 changes: 25 additions & 3 deletions src/cache_maint.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ static void cache_file_move(const gchar *src, const gchar *dest)
}
}

void cache_maint_moved(FileData *fd)
static void cache_maint_moved(FileData *fd)
{
gchar *base;
mode_t mode = 0755;
Expand Down Expand Up @@ -579,7 +579,7 @@ static void cache_file_remove(const gchar *path)
}
}

void cache_maint_removed(FileData *fd)
static void cache_maint_removed(FileData *fd)
{
gchar *buf;

Expand All @@ -599,7 +599,7 @@ void cache_maint_removed(FileData *fd)
thumb_std_maint_removed(fd->path);
}

void cache_maint_copied(FileData *fd)
static void cache_maint_copied(FileData *fd)
{
gchar *dest_base;
gchar *src_cache;
Expand All @@ -625,6 +625,28 @@ void cache_maint_copied(FileData *fd)
g_free(src_cache);
}

void cache_notify_cb(FileData *fd, NotifyType type, gpointer data)
{
if (!fd->change) return;

switch(fd->change->type)
{
case FILEDATA_CHANGE_MOVE:
case FILEDATA_CHANGE_RENAME:
cache_maint_moved(fd);
break;
case FILEDATA_CHANGE_COPY:
cache_maint_copied(fd);
break;
case FILEDATA_CHANGE_DELETE:
cache_maint_removed(fd);
break;
case FILEDATA_CHANGE_UNSPECIFIED:
break;
}
}


/*
*-------------------------------------------------------------------
* new cache maintenance utilities
Expand Down
4 changes: 1 addition & 3 deletions src/cache_maint.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear);
gint cache_maintain_dir(const gchar *dir, gint recursive, gint clear);
#endif

void cache_maint_moved(FileData *fd);
void cache_maint_removed(FileData *fd);
void cache_maint_copied(FileData *fd);
void cache_notify_cb(FileData *fd, NotifyType type, gpointer data);


void cache_manager_show(void);
Expand Down
5 changes: 5 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ui_bookmark.h"
#include "ui_fileops.h"
#include "ui_utildlg.h"
#include "cache_maint.h"

#include <gdk/gdkkeysyms.h> /* for keyboard values */

Expand Down Expand Up @@ -679,6 +680,10 @@ int main(int argc, char *argv[])
#if 1
log_printf("%s %s, This is an alpha release.\n", GQ_APPNAME, VERSION);
#endif

/* register global notify functions */
file_data_register_notify_func(cache_notify_cb, NULL, NOTIFY_PRIORITY_HIGH);

parse_command_line_for_debug_option(argc, argv);

options = init_options(NULL);
Expand Down
4 changes: 0 additions & 4 deletions src/utilops.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ void file_data_notify_ci(FileData *fd)
switch (type)
{
case FILEDATA_CHANGE_MOVE:
cache_maint_moved(fd);
collection_maint_renamed(fd);

layout_maint_moved(fd, NULL);
Expand All @@ -252,10 +251,8 @@ void file_data_notify_ci(FileData *fd)
search_maint_renamed(fd);
break;
case FILEDATA_CHANGE_COPY:
cache_maint_copied(fd);
break;
case FILEDATA_CHANGE_RENAME:
cache_maint_moved(fd);
collection_maint_renamed(fd);

layout_maint_renamed(fd);
Expand All @@ -270,7 +267,6 @@ void file_data_notify_ci(FileData *fd)
search_maint_removed(fd);

collection_maint_removed(fd);
cache_maint_removed(fd);
break;
case FILEDATA_CHANGE_UNSPECIFIED:
/* FIXME */
Expand Down

0 comments on commit dd62fe1

Please sign in to comment.