changeset 796:0be132a51f51

use new notification in layout and layout_image
author nadvornik
date Sat, 07 Jun 2008 09:10:01 +0000
parents a31524ae39cb
children 799d035b9994
files src/layout.c src/layout.h src/layout_image.c src/layout_image.h src/typedefs.h src/utilops.c
diffstat 6 files changed, 28 insertions(+), 131 deletions(-) [+]
line wrap: on
line diff
--- a/src/layout.c	Sat Jun 07 08:13:22 2008 +0000
+++ b/src/layout.c	Sat Jun 07 09:10:01 2008 +0000
@@ -906,8 +906,6 @@
 {
 	if (!lw->dir_fd) return;
 
-	lw->last_version = lw->dir_fd->version;
-
 	if (lw->path_entry) gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->dir_fd->path);
 	if (lw->vd) vd_set_fd(lw->vd, lw->dir_fd);
 
@@ -1000,23 +998,11 @@
 
 static void layout_refresh_lists(LayoutWindow *lw)
 {
-	if (lw->dir_fd) lw->last_version = lw->dir_fd->version;
-
 	if (lw->vd) vd_refresh(lw->vd);
 
 	if (lw->vf) vf_refresh(lw->vf);
 }
 
-static void layout_refresh_by_time(LayoutWindow *lw)
-{
-	layout_refresh_lists(lw);
-
-	if (lw->image && layout_image_get_fd(lw)->version != lw->last_version) // FIXME - move to layout_image and fix
-		{
-		layout_image_refresh(lw);
-		}
-}
-
 void layout_refresh(LayoutWindow *lw)
 {
 	if (!layout_valid(&lw)) return;
@@ -1028,24 +1014,6 @@
 	if (lw->image) layout_image_refresh(lw);
 }
 
-static gint layout_check_for_update_cb(gpointer data)
-{
-	LayoutWindow *lw = data;
-
-	if (!options->update_on_time_change) return TRUE;
-
-	if (lw->dir_fd)
-		{
-		if (lw->dir_fd->version != lw->last_version)
-			{
-			DEBUG_1("layout path time changed, refreshing...");
-			layout_refresh_by_time(lw);
-			}
-		}
-
-	return TRUE;
-}
-
 void layout_thumb_set(LayoutWindow *lw, gint enable)
 {
 	if (!layout_valid(&lw)) return;
@@ -1827,6 +1795,7 @@
 		}
 	else
 		{
+		layout_free(lw); /* make leak detection easier */
 		exit_program();
 		}
 }
@@ -1842,6 +1811,8 @@
 
 	gtk_widget_destroy(lw->window);
 
+	file_data_unregister_notify_func(layout_image_notify_cb, lw);
+
 	if (lw->dir_fd) 
 		{
 		file_data_unregister_real_time_monitor(lw->dir_fd);
@@ -1988,10 +1959,6 @@
 		gdk_pixbuf_unref(pixbuf);
 		}
 
-	/* set up the time stat timeout */
-	lw->last_version = 0;
-//	lw->last_time_id = g_timeout_add(5000, layout_check_for_update_cb, lw);
-
 	if (geometry)
 		{
 		if (!gtk_window_parse_geometry(GTK_WINDOW(lw->window), geometry))
@@ -2005,81 +1972,8 @@
 
 	layout_window_list = g_list_append(layout_window_list, lw);
 
+	file_data_register_notify_func(layout_image_notify_cb, lw, NOTIFY_PRIORITY_LOW);
+
 	return lw;
 }
 
-/*
- *-----------------------------------------------------------------------------
- * maintenance (for rename, move, remove)
- *-----------------------------------------------------------------------------
- */
-
-static void layout_real_time_update(LayoutWindow *lw)
-{
-	/* this resets the last time stamp of path so that a refresh does not occur
-	 * from an internal file operation. FIXME
-	 */
-
-	if (lw->dir_fd) lw->last_version = lw->dir_fd->version;
-}
-
-static void layout_real_renamed(LayoutWindow *lw, FileData *fd)
-{
-	if (lw->image) layout_image_maint_renamed(lw, fd);
-
-//	if (lw->vf && vf_maint_renamed(lw->vf, fd))
-		layout_real_time_update(lw);
-		
-}
-
-static void layout_real_removed(LayoutWindow *lw, FileData *fd, GList *ignore_list)
-{
-	if (lw->image) layout_image_maint_removed(lw, fd);
-
-//	if (lw->vf && vf_maint_removed(lw->vf, fd, ignore_list))
-		layout_real_time_update(lw);
-}
-
-static void layout_real_moved(LayoutWindow *lw, FileData *fd, GList *ignore_list)
-{
-	if (lw->image) layout_image_maint_moved(lw, fd);
-
-//	if (lw->vf && vf_maint_moved(lw->vf, fd, ignore_list))
-		layout_real_time_update(lw);
-}
-
-void layout_maint_renamed(FileData *fd)
-{
-	GList *work = layout_window_list;
-	while (work)
-		{
-		LayoutWindow *lw = work->data;
-		work = work->next;
-
-		layout_real_renamed(lw, fd);
-		}
-}
-
-void layout_maint_removed(FileData *fd, GList *ignore_list)
-{
-	GList *work = layout_window_list;
-	while (work)
-		{
-		LayoutWindow *lw = work->data;
-		work = work->next;
-
-		layout_real_removed(lw, fd, ignore_list);
-		}
-}
-
-void layout_maint_moved(FileData *fd, GList *ignore_list)
-{
-	GList *work = layout_window_list;
-	while (work)
-		{
-		LayoutWindow *lw = work->data;
-		work = work->next;
-
-		layout_real_moved(lw, fd, ignore_list);
-		}
-}
--- a/src/layout.h	Sat Jun 07 08:13:22 2008 +0000
+++ b/src/layout.h	Sat Jun 07 09:10:01 2008 +0000
@@ -94,9 +94,4 @@
 
 void layout_split_change(LayoutWindow *lw, ImageSplitMode mode);
 
-void layout_maint_renamed(FileData *fd);
-void layout_maint_removed(FileData *fd, GList *ignore_list);
-void layout_maint_moved(FileData *fd, GList *ignore_list);
-
-
 #endif
--- a/src/layout_image.c	Sat Jun 07 08:13:22 2008 +0000
+++ b/src/layout_image.c	Sat Jun 07 09:10:01 2008 +0000
@@ -2047,7 +2047,7 @@
  *-----------------------------------------------------------------------------
  */
 
-void layout_image_maint_renamed(LayoutWindow *lw, FileData *fd)
+static void layout_image_maint_renamed(LayoutWindow *lw, FileData *fd)
 {
 	FileData *img_fd;
 
@@ -2059,7 +2059,7 @@
 		}
 }
 
-void layout_image_maint_removed(LayoutWindow *lw, FileData *fd)
+static void layout_image_maint_removed(LayoutWindow *lw, FileData *fd)
 {
 	FileData *img_fd;
 
@@ -2088,7 +2088,25 @@
 		}
 }
 
-void layout_image_maint_moved(LayoutWindow *lw, FileData *fd)
+
+void layout_image_notify_cb(FileData *fd, NotifyType type, gpointer data)
 {
-	layout_image_maint_renamed(lw, fd);
+	LayoutWindow *lw = data;
+
+	if (!fd->change) return;
+	
+	switch(fd->change->type)
+		{
+		case FILEDATA_CHANGE_MOVE:
+		case FILEDATA_CHANGE_RENAME:
+			layout_image_maint_renamed(lw, fd);
+			break;
+		case FILEDATA_CHANGE_DELETE:
+			layout_image_maint_removed(lw, fd);
+			break;
+		case FILEDATA_CHANGE_COPY:
+		case FILEDATA_CHANGE_UNSPECIFIED:
+			break;
+		}
+
 }
--- a/src/layout_image.h	Sat Jun 07 08:13:22 2008 +0000
+++ b/src/layout_image.h	Sat Jun 07 09:10:01 2008 +0000
@@ -78,9 +78,6 @@
 
 void layout_image_overlay_toggle(LayoutWindow *lw);
 
-void layout_image_maint_renamed(LayoutWindow *lw, FileData *fd);
-void layout_image_maint_removed(LayoutWindow *lw, FileData *fd);
-void layout_image_maint_moved(LayoutWindow *lw, FileData *fd);
-
+void layout_image_notify_cb(FileData *fd, NotifyType type, gpointer data);
 
 #endif
--- a/src/typedefs.h	Sat Jun 07 08:13:22 2008 +0000
+++ b/src/typedefs.h	Sat Jun 07 09:10:01 2008 +0000
@@ -549,10 +549,6 @@
 	gint div_v;
 	gint div_float;
 
-	/* directory update check */
-
-	gint last_version;
-
 	/* misc */
 
 	GtkWidget *utility_box;
--- a/src/utilops.c	Sat Jun 07 08:13:22 2008 +0000
+++ b/src/utilops.c	Sat Jun 07 09:10:01 2008 +0000
@@ -245,7 +245,6 @@
 		case FILEDATA_CHANGE_MOVE:
 			collection_maint_renamed(fd);
 
-			layout_maint_moved(fd, NULL);
 			view_window_maint_moved(fd);
 			break;
 		case FILEDATA_CHANGE_COPY:
@@ -253,11 +252,9 @@
 		case FILEDATA_CHANGE_RENAME:
 			collection_maint_renamed(fd);
 
-			layout_maint_renamed(fd);
 			view_window_maint_moved(fd);
 			break;
 		case FILEDATA_CHANGE_DELETE:
-			layout_maint_removed(fd, NULL);
 			view_window_maint_removed(fd, NULL);
 
 			collection_maint_removed(fd);