Mercurial > geeqie.yaz
comparison src/filedata.c @ 784:16b3a5c8aedc
new notification system (used only in vflist for now)
author | nadvornik |
---|---|
date | Wed, 04 Jun 2008 21:12:47 +0000 |
parents | d6a7fb4b8e7c |
children | 548b193c084c |
comparison
equal
deleted
inserted
replaced
783:d6a7fb4b8e7c | 784:16b3a5c8aedc |
---|---|
138 | 138 |
139 void file_data_increment_version(FileData *fd) | 139 void file_data_increment_version(FileData *fd) |
140 { | 140 { |
141 fd->version++; | 141 fd->version++; |
142 if (fd->parent) fd->parent->version++; | 142 if (fd->parent) fd->parent->version++; |
143 | |
144 file_data_send_notification(fd); /* FIXME there are probably situations when we don't want to call this */ | |
143 } | 145 } |
144 | 146 |
145 | 147 |
146 static void file_data_set_path(FileData *fd, const gchar *path) | 148 static void file_data_set_path(FileData *fd, const gchar *path) |
147 { | 149 { |
1388 | 1390 |
1389 /* might use file_maint_ functions for now, later it should be changed to a system of callbacks | 1391 /* might use file_maint_ functions for now, later it should be changed to a system of callbacks |
1390 FIXME do we need the ignore_list? It looks like a workaround for ineffective | 1392 FIXME do we need the ignore_list? It looks like a workaround for ineffective |
1391 implementation in view_file_list.c */ | 1393 implementation in view_file_list.c */ |
1392 | 1394 |
1395 | |
1396 | |
1397 | |
1398 typedef struct _NotifyData NotifyData; | |
1399 | |
1400 struct _NotifyData { | |
1401 FileDataNotifyFunc func; | |
1402 gpointer data; | |
1403 }; | |
1404 | |
1405 static GList *notify_func_list = NULL; | |
1406 | |
1407 gint file_data_register_notify_func(FileDataNotifyFunc func, gpointer data) | |
1408 { | |
1409 NotifyData *nd = g_new(NotifyData, 1); | |
1410 nd->func = func; | |
1411 nd->data = data; | |
1412 notify_func_list = g_list_prepend(notify_func_list, nd); | |
1413 DEBUG_1("Notify func registered: %p\n", nd); | |
1414 return TRUE; | |
1415 } | |
1416 | |
1417 gint file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data) | |
1418 { | |
1419 GList *work = notify_func_list; | |
1420 | |
1421 while(work) | |
1422 { | |
1423 NotifyData *nd = (NotifyData *)work->data; | |
1424 if (nd->func == func && nd->data == data) | |
1425 { | |
1426 notify_func_list = g_list_delete_link(notify_func_list, work); | |
1427 g_free(nd); | |
1428 DEBUG_1("Notify func unregistered: %p\n", nd); | |
1429 return TRUE; | |
1430 } | |
1431 work = work->next; | |
1432 } | |
1433 return FALSE; | |
1434 } | |
1435 | |
1436 | |
1437 void file_data_send_notification(FileData *fd) | |
1438 { | |
1439 GList *work = notify_func_list; | |
1440 while(work) | |
1441 { | |
1442 NotifyData *nd = (NotifyData *)work->data; | |
1443 DEBUG_1("Notify func calling: %p %s\n", nd, fd->path); | |
1444 nd->func(fd, nd->data); | |
1445 work = work->next; | |
1446 } | |
1447 } | |
1448 | |
1393 void file_data_sc_send_notification(FileData *fd) | 1449 void file_data_sc_send_notification(FileData *fd) |
1394 { | 1450 { |
1395 } | 1451 } |
1396 | 1452 |
1397 | 1453 |
1454 | |
1455 | |
1456 | |
1457 | |
1458 | |
1459 | |
1460 |