Mercurial > geeqie
changeset 800:a25b228978a0
various notification improvements
author | nadvornik |
---|---|
date | Sat, 07 Jun 2008 15:08:33 +0000 |
parents | 278962ba162a |
children | 9b676bb76a2e |
files | src/filedata.c src/filedata.h src/image-overlay.c src/typedefs.h src/utilops.c src/view_file_icon.c src/view_file_list.c |
diffstat | 7 files changed, 62 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/src/filedata.c Sat Jun 07 10:45:33 2008 +0000 +++ b/src/filedata.c Sat Jun 07 15:08:33 2008 +0000 @@ -142,8 +142,6 @@ { fd->version++; if (fd->parent) fd->parent->version++; - - file_data_send_notification(fd, NOTIFY_TYPE_REREAD); /* FIXME there are probably situations when we don't want to call this */ } static void file_data_set_collate_keys(FileData *fd) @@ -233,6 +231,7 @@ if (fd->pixbuf) g_object_unref(fd->pixbuf); fd->pixbuf = NULL; file_data_increment_version(fd); + file_data_send_notification(fd, NOTIFY_TYPE_REREAD); } work = fd->sidecar_files; @@ -915,6 +914,41 @@ } +/* + * marks and orientation + */ + + +gboolean file_data_get_mark(FileData *fd, gint n) +{ + return !!(fd->marks & (1 << n)); +} + +void file_data_set_mark(FileData *fd, gint n, gboolean value) +{ + if (!value == !(fd->marks & (1 << n))) return; + + fd->marks = fd->marks ^ (1 << n); + file_data_increment_version(fd); + file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); + +} + +gint file_data_get_user_orientation(FileData *fd) +{ + return fd->user_orientation; +} + +void file_data_set_user_orientation(FileData *fd, gint value) +{ + if (fd->user_orientation == value) return; + + fd->user_orientation = value; + file_data_increment_version(fd); + file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); +} + + /* * file_data - operates on the given fd @@ -1407,6 +1441,7 @@ file_data_set_path(fd, fd->change->dest); } file_data_increment_version(fd); + file_data_send_notification(fd, NOTIFY_TYPE_CHANGE); } gint file_data_sc_apply_ci(FileData *fd) @@ -1500,11 +1535,6 @@ } } -void file_data_sc_send_notification(FileData *fd) -{ -} - - static GHashTable *file_data_monitor_pool = NULL; static gint realtime_monitor_id = -1; @@ -1513,9 +1543,10 @@ FileData *fd = key; struct stat st; - stat_utf8(fd->path, &st); - - file_data_check_changed_files(fd, &st); + if (stat_utf8(fd->path, &st)) + file_data_check_changed_files(fd, &st); + else + file_data_send_notification(fd, NOTIFY_TYPE_REREAD); DEBUG_1("monitor %s", fd->path); }
--- a/src/filedata.h Sat Jun 07 10:45:33 2008 +0000 +++ b/src/filedata.h Sat Jun 07 15:08:33 2008 +0000 @@ -48,6 +48,11 @@ GList *filelist_sort_path(GList *list); GList *filelist_recursive(FileData *dir_fd); +gboolean file_data_get_mark(FileData *fd, gint n); +void file_data_set_mark(FileData *fd, gint n, gboolean value); +gint file_data_get_user_orientation(FileData *fd); +void file_data_set_user_orientation(FileData *fd, gint value); + gchar *file_data_sc_list_to_string(FileData *fd); gboolean file_data_add_ci(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest); gboolean file_data_sc_add_ci_copy(FileData *fd, const gchar *dest_path);
--- a/src/image-overlay.c Sat Jun 07 10:45:33 2008 +0000 +++ b/src/image-overlay.c Sat Jun 07 15:08:33 2008 +0000 @@ -539,7 +539,7 @@ for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++) { - active_marks += fd->marks[mark]; + active_marks += file_data_get_mark(fd, mark); } if (active_marks > 0) @@ -548,7 +548,7 @@ for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++) { - g_string_append_printf(buf, fd->marks[mark] ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + mark); + g_string_append_printf(buf, file_data_get_mark(fd, mark) ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + mark); } if (*text)
--- a/src/typedefs.h Sat Jun 07 10:45:33 2008 +0000 +++ b/src/typedefs.h Sat Jun 07 15:08:33 2008 +0000 @@ -441,7 +441,7 @@ gchar *collate_key_name_nocase; gint64 size; time_t date; - gboolean marks[FILEDATA_MARKS_SIZE]; + gint marks; GList *sidecar_files; FileData *parent; /* parent file if this is a sidecar file, NULL otherwise */ FileDataChangeInfo *change; /* for rename, move ... */
--- a/src/utilops.c Sat Jun 07 10:45:33 2008 +0000 +++ b/src/utilops.c Sat Jun 07 15:08:33 2008 +0000 @@ -229,37 +229,6 @@ -/* - *-------------------------------------------------------------------------- - * call these when names change, files move, deleted, etc. - * so that any open windows are also updated - *-------------------------------------------------------------------------- - */ - -/* FIXME this is a temporary solution */ -void file_data_notify_ci(FileData *fd) -{ - - /* this is the new way: */ - file_data_send_notification(fd, NOTIFY_TYPE_CHANGE); -} - -void file_data_sc_notify_ci(FileData *fd) -{ - GList *work; - if (fd->parent) fd = fd->parent; - - file_data_notify_ci(fd); - - work = fd->sidecar_files; - while (work) - { - FileData *sfd = work->data; - file_data_notify_ci(sfd); - work = work->next; - } -} - typedef enum { UTILITY_TYPE_COPY, @@ -554,7 +523,6 @@ if (!(flags & EDITOR_ERROR_MASK)) /* files were successfully deleted, call the maint functions */ { file_data_sc_apply_ci(fd); - file_data_sc_notify_ci(fd); } ud->flist = g_list_remove(ud->flist, fd);
--- a/src/view_file_icon.c Sat Jun 07 10:45:33 2008 +0000 +++ b/src/view_file_icon.c Sat Jun 07 15:08:33 2008 +0000 @@ -916,7 +916,7 @@ g_assert(fd->magick == 0x12345678); - mark_val = fd->marks[n]; + mark_val = file_data_get_mark(fd, n); selected = (id->selected & SELECTION_SELECTED); switch (mode) @@ -953,15 +953,13 @@ switch (mode) { - case STM_MODE_SET: fd->marks[n] = 1; + case STM_MODE_SET: file_data_set_mark(fd, n, 1); break; - case STM_MODE_RESET: fd->marks[n] = 0; + case STM_MODE_RESET: file_data_set_mark(fd, n, 0); break; - case STM_MODE_TOGGLE: fd->marks[n] = !fd->marks[mark]; + case STM_MODE_TOGGLE: file_data_set_mark(fd, n, !file_data_get_mark(fd, n)); break; } - file_data_increment_version(fd); - work = work->next; } filelist_free(slist);
--- a/src/view_file_list.c Sat Jun 07 10:45:33 2008 +0000 +++ b/src/view_file_list.c Sat Jun 07 15:08:33 2008 +0000 @@ -726,7 +726,7 @@ FILE_COLUMN_DATE, text_from_time(fd->date), FILE_COLUMN_COLOR, FALSE, -1); for (i = 0; i < FILEDATA_MARKS_SIZE; i++) - gtk_tree_store_set(store, iter, FILE_COLUMN_MARKS + i, fd->marks[i], -1); + gtk_tree_store_set(store, iter, FILE_COLUMN_MARKS + i, file_data_get_mark(fd, i), -1); g_free(size); if (sidecars) @@ -1405,7 +1405,7 @@ gboolean mark_val, selected; gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, -1); - mark_val = fd->marks[n]; + mark_val = file_data_get_mark(fd, n); selected = gtk_tree_selection_iter_is_selected(selection, &iter); switch (mode) @@ -1451,21 +1451,21 @@ gtk_tree_model_get_iter(store, &iter, tpath); gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); + file_data_unregister_notify_func(vflist_notify_cb, vf); /* we don't need the notification */ + switch (mode) { - case STM_MODE_SET: fd->marks[n] = 1; + case STM_MODE_SET: file_data_set_mark(fd, n, 1); break; - case STM_MODE_RESET: fd->marks[n] = 0; + case STM_MODE_RESET: file_data_set_mark(fd, n, 0); break; - case STM_MODE_TOGGLE: fd->marks[n] = !fd->marks[n]; + case STM_MODE_TOGGLE: file_data_set_mark(fd, n, !file_data_get_mark(fd, n)); 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, NOTIFY_PRIORITY_MEDIUM); - gtk_tree_store_set(GTK_TREE_STORE(store), &iter, FILE_COLUMN_MARKS + n, fd->marks[n], -1); + gtk_tree_store_set(GTK_TREE_STORE(store), &iter, FILE_COLUMN_MARKS + n, file_data_get_mark(fd, n), -1); work = work->next; } @@ -1708,9 +1708,8 @@ 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_set_mark(fd, col_idx - FILE_COLUMN_MARKS, mark); file_data_register_notify_func(vflist_notify_cb, vf, NOTIFY_PRIORITY_MEDIUM); gtk_tree_store_set(store, &iter, col_idx, mark, -1);