{
fd->version++;
if (fd->parent) fd->parent->version++;
+
+ file_data_send_notification(fd); /* FIXME there are probably situations when we don't want to call this */
}
FIXME do we need the ignore_list? It looks like a workaround for ineffective
implementation in view_file_list.c */
+
+
+
+typedef struct _NotifyData NotifyData;
+
+struct _NotifyData {
+ FileDataNotifyFunc func;
+ gpointer data;
+ };
+
+static GList *notify_func_list = NULL;
+
+gint file_data_register_notify_func(FileDataNotifyFunc func, gpointer data)
+{
+ NotifyData *nd = g_new(NotifyData, 1);
+ nd->func = func;
+ nd->data = data;
+ notify_func_list = g_list_prepend(notify_func_list, nd);
+ DEBUG_1("Notify func registered: %p\n", nd);
+ return TRUE;
+}
+
+gint file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data)
+{
+ GList *work = notify_func_list;
+
+ while(work)
+ {
+ NotifyData *nd = (NotifyData *)work->data;
+ if (nd->func == func && nd->data == data)
+ {
+ notify_func_list = g_list_delete_link(notify_func_list, work);
+ g_free(nd);
+ DEBUG_1("Notify func unregistered: %p\n", nd);
+ return TRUE;
+ }
+ work = work->next;
+ }
+ return FALSE;
+}
+
+
+void file_data_send_notification(FileData *fd)
+{
+ GList *work = notify_func_list;
+ while(work)
+ {
+ NotifyData *nd = (NotifyData *)work->data;
+ DEBUG_1("Notify func calling: %p %s\n", nd, fd->path);
+ nd->func(fd, nd->data);
+ work = work->next;
+ }
+}
+
void file_data_sc_send_notification(FileData *fd)
{
}
+
+
+
+
+
+
+
switch(vf->type)
{
- case FILEVIEW_LIST: ret = vflist_maint_renamed(vf, fd); break;
+// case FILEVIEW_LIST: ret = vflist_maint_renamed(vf, fd); break;
case FILEVIEW_ICON: ret = vficon_maint_renamed(vf, fd); break;
}
switch(vf->type)
{
- case FILEVIEW_LIST: ret = vflist_maint_removed(vf, fd, ignore_list); break;
+// case FILEVIEW_LIST: ret = vflist_maint_removed(vf, fd, ignore_list); break;
case FILEVIEW_ICON: ret = vficon_maint_removed(vf, fd, ignore_list); break;
}
switch(vf->type)
{
- case FILEVIEW_LIST: ret = vflist_maint_moved(vf, fd, ignore_list); break;
+// case FILEVIEW_LIST: ret = vflist_maint_moved(vf, fd, ignore_list); break;
case FILEVIEW_ICON: ret = vficon_maint_moved(vf, fd, ignore_list); break;
}
static gint vflist_row_is_selected(ViewFile *vf, FileData *fd);
static gint vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data);
static void vflist_populate_view(ViewFile *vf);
+static void vflist_notify_cb(FileData *fd, gpointer data);
/*
break;
}
+ file_data_unregister_notify_func(vflist_notify_cb, vf); /* we don't need the notification */
file_data_increment_version(fd);
+ file_data_register_notify_func(vflist_notify_cb, vf);
gtk_tree_store_set(GTK_TREE_STORE(store), &iter, FILE_COLUMN_MARKS + n, fd->marks[n], -1);
DEBUG_1("%s vflist_refresh: read dir", get_exec_time());
if (vf->dir_fd)
{
+ file_data_unregister_notify_func(vflist_notify_cb, vf); /* we don't need the notification of changes detected by filelist_read */
+
ret = filelist_read(vf->dir_fd, &vf->list, NULL);
+ file_data_register_notify_func(vflist_notify_cb, vf);
+
DEBUG_1("%s vflist_refresh: sort", get_exec_time());
vf->list = filelist_sort(vf->list, vf->sort_method, vf->sort_ascend);
}
gtk_tree_view_append_column(GTK_TREE_VIEW(vf->listview), column);
}
-static void vflist_listview_mark_toggled(GtkCellRendererToggle *cell, gchar *path_str, GtkTreeStore *store)
+static void vflist_listview_mark_toggled_cb(GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
{
+ ViewFile *vf = data;
+ GtkTreeStore *store;
GtkTreePath *path = gtk_tree_path_new_from_string(path_str);
GtkTreeIter iter;
FileData *fd;
gboolean mark;
guint col_idx;
+ store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
if (!path || !gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path))
return;
gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, col_idx, &mark, -1);
mark = !mark;
fd->marks[col_idx - FILE_COLUMN_MARKS] = mark;
+ file_data_unregister_notify_func(vflist_notify_cb, vf); /* we don't need the notification */
file_data_increment_version(fd);
+ file_data_register_notify_func(vflist_notify_cb, vf);
gtk_tree_store_set(store, &iter, col_idx, mark, -1);
gtk_tree_path_free(path);
gtk_tree_view_column_set_visible(column, vf->marks_enabled);
- g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(vflist_listview_mark_toggled), store);
+ g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(vflist_listview_mark_toggled_cb), vf);
}
/*
{
ViewFile *vf = data;
+ file_data_unregister_notify_func(vflist_notify_cb, vf);
+
vflist_select_idle_cancel(vf);
vflist_refresh_idle_cancel(vf);
vflist_thumb_stop(vf);
vflist_listview_add_column(vf, FILE_COLUMN_SIZE, _("Size"), FALSE, TRUE, FALSE);
vflist_listview_add_column(vf, FILE_COLUMN_DATE, _("Date"), FALSE, TRUE, FALSE);
+ file_data_register_notify_func(vflist_notify_cb, vf);
return vf;
}
*-----------------------------------------------------------------------------
*/
-void vflist_maint(ViewFile *vf, FileData *fd)
+static void vflist_notify_cb(FileData *fd, gpointer data)
{
+ ViewFile *vf = data;
gboolean refresh;
if (vf->refresh_idle_id != -1) return;
refresh = (fd == vf->dir_fd);
- if (!refresh && fd->change->dest)
+ if (!refresh)
{
gchar *base = remove_level_from_path(fd->path);
refresh = (strcmp(base, vf->dir_fd->path) == 0);
g_free(base);
}
- if (!refresh && fd->change->dest)
+ if (!refresh && fd->change && fd->change->dest)
{
gchar *dest_base = remove_level_from_path(fd->change->dest);
refresh = (strcmp(dest_base, vf->dir_fd->path) == 0);
g_free(dest_base);
}
- if (!refresh && fd->change->source)
+ if (!refresh && fd->change && fd->change->source)
{
gchar *source_base = remove_level_from_path(fd->change->source);
refresh = (strcmp(source_base, vf->dir_fd->path) == 0);
}
}
-/* the plan is to drop these functions and use vflist_maint directly */
+#if 0
gint vflist_maint_renamed(ViewFile *vf, FileData *fd)
{
}
-#if 0
static gint vflist_maint_find_closest(ViewFile *vf, gint row, gint count, GList *ignore_list)
{
GList *list = NULL;