Compare commits
3 Commits
cc59e537da
...
bd92ad73ec
Author | SHA1 | Date | |
---|---|---|---|
bd92ad73ec | |||
b3bc481172 | |||
a3745df84b |
@ -330,6 +330,36 @@ model_find(const GPtrArray *target, GFile *file, FivIoModelEntry **entry)
|
||||
return -1;
|
||||
}
|
||||
|
||||
enum monitor_event {
|
||||
MONITOR_NONE,
|
||||
MONITOR_CHANGING,
|
||||
MONITOR_RENAMING,
|
||||
MONITOR_REMOVING,
|
||||
MONITOR_ADDING
|
||||
};
|
||||
|
||||
static void
|
||||
monitor_apply(enum monitor_event event, GPtrArray *target, int index,
|
||||
FivIoModelEntry *new_entry)
|
||||
{
|
||||
// The file used to be filtered out but isn't anymore.
|
||||
// TODO(p): Handle the inverse transition as well.
|
||||
if (event == MONITOR_RENAMING && index < 0)
|
||||
event = MONITOR_ADDING;
|
||||
|
||||
if (event == MONITOR_CHANGING) {
|
||||
g_assert(new_entry != NULL);
|
||||
fiv_io_model_entry_unref(target->pdata[index]);
|
||||
target->pdata[index] = fiv_io_model_entry_ref(new_entry);
|
||||
}
|
||||
if (event == MONITOR_REMOVING || event == MONITOR_RENAMING)
|
||||
g_ptr_array_remove_index(target, index);
|
||||
if (event == MONITOR_RENAMING || event == MONITOR_ADDING) {
|
||||
g_assert(new_entry != NULL);
|
||||
g_ptr_array_add(target, fiv_io_model_entry_ref(new_entry));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_monitor_changed(G_GNUC_UNUSED GFileMonitor *monitor, GFile *file,
|
||||
GFile *other_file, GFileMonitorEvent event_type, gpointer user_data)
|
||||
@ -340,25 +370,25 @@ on_monitor_changed(G_GNUC_UNUSED GFileMonitor *monitor, GFile *file,
|
||||
gint files_index = model_find(self->files, file, &old_entry);
|
||||
gint subdirs_index = model_find(self->subdirs, file, &old_entry);
|
||||
|
||||
enum { NONE, CHANGING, RENAMING, REMOVING, ADDING } action = NONE;
|
||||
enum monitor_event action = MONITOR_NONE;
|
||||
GFile *new_entry_file = NULL;
|
||||
switch (event_type) {
|
||||
case G_FILE_MONITOR_EVENT_CHANGED:
|
||||
case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
|
||||
action = CHANGING;
|
||||
action = MONITOR_CHANGING;
|
||||
new_entry_file = file;
|
||||
break;
|
||||
case G_FILE_MONITOR_EVENT_RENAMED:
|
||||
action = RENAMING;
|
||||
action = MONITOR_RENAMING;
|
||||
new_entry_file = other_file;
|
||||
break;
|
||||
case G_FILE_MONITOR_EVENT_DELETED:
|
||||
case G_FILE_MONITOR_EVENT_MOVED_OUT:
|
||||
action = REMOVING;
|
||||
action = MONITOR_REMOVING;
|
||||
break;
|
||||
case G_FILE_MONITOR_EVENT_CREATED:
|
||||
case G_FILE_MONITOR_EVENT_MOVED_IN:
|
||||
action = ADDING;
|
||||
action = MONITOR_ADDING;
|
||||
old_entry = NULL;
|
||||
new_entry_file = file;
|
||||
break;
|
||||
@ -402,36 +432,12 @@ run:
|
||||
fiv_io_model_entry_ref(old_entry);
|
||||
|
||||
if (files_index != -1 || new_target == self->files) {
|
||||
if (action == CHANGING) {
|
||||
g_assert(new_entry != NULL);
|
||||
fiv_io_model_entry_unref(self->files->pdata[files_index]);
|
||||
self->files->pdata[files_index] =
|
||||
fiv_io_model_entry_ref(new_entry);
|
||||
}
|
||||
if (action == REMOVING || action == RENAMING)
|
||||
g_ptr_array_remove_index(self->files, files_index);
|
||||
if (action == RENAMING || action == ADDING) {
|
||||
g_assert(new_entry != NULL);
|
||||
g_ptr_array_add(self->files, fiv_io_model_entry_ref(new_entry));
|
||||
}
|
||||
|
||||
monitor_apply(action, self->files, files_index, new_entry);
|
||||
g_signal_emit(self, model_signals[FILES_CHANGED],
|
||||
0, old_entry, new_entry);
|
||||
}
|
||||
if (subdirs_index != -1 || new_target == self->subdirs) {
|
||||
if (action == CHANGING) {
|
||||
g_assert(new_entry != NULL);
|
||||
fiv_io_model_entry_unref(self->subdirs->pdata[subdirs_index]);
|
||||
self->subdirs->pdata[subdirs_index] =
|
||||
fiv_io_model_entry_ref(new_entry);
|
||||
}
|
||||
if (action == REMOVING || action == RENAMING)
|
||||
g_ptr_array_remove_index(self->subdirs, subdirs_index);
|
||||
if (action == RENAMING || action == ADDING) {
|
||||
g_assert(new_entry != NULL);
|
||||
g_ptr_array_add(self->subdirs, fiv_io_model_entry_ref(new_entry));
|
||||
}
|
||||
|
||||
monitor_apply(action, self->subdirs, subdirs_index, new_entry);
|
||||
g_signal_emit(self, model_signals[SUBDIRECTORIES_CHANGED],
|
||||
0, old_entry, new_entry);
|
||||
}
|
||||
|
@ -46,12 +46,23 @@ parse_raw(jv o, const uint8_t *p, size_t len)
|
||||
return add_error(o, libraw_strerror(err));
|
||||
}
|
||||
|
||||
// -> iprc->rawparams.shot_select
|
||||
o = jv_set(o, jv_string("count"), jv_number(iprc->idata.raw_count));
|
||||
|
||||
o = jv_set(o, jv_string("width"), jv_number(iprc->sizes.width));
|
||||
o = jv_set(o, jv_string("height"), jv_number(iprc->sizes.height));
|
||||
o = jv_set(o, jv_string("flip"), jv_number(iprc->sizes.flip));
|
||||
o = jv_set(o, jv_string("pixel_aspect_ratio"),
|
||||
jv_number(iprc->sizes.pixel_aspect));
|
||||
|
||||
// -> iprc->rawparams.shot_select
|
||||
o = jv_set(o, jv_string("count"), jv_number(iprc->idata.raw_count));
|
||||
if ((err = libraw_adjust_sizes_info_only(iprc))) {
|
||||
o = add_warning(o, libraw_strerror(err));
|
||||
} else {
|
||||
o = jv_set(
|
||||
o, jv_string("output_width"), jv_number(iprc->sizes.iwidth));
|
||||
o = jv_set(
|
||||
o, jv_string("output_height"), jv_number(iprc->sizes.iheight));
|
||||
}
|
||||
|
||||
jv thumbnails = jv_array();
|
||||
for (int i = 0; i < iprc->thumbs_list.thumbcount; i++) {
|
||||
@ -91,11 +102,20 @@ parse_raw(jv o, const uint8_t *p, size_t len)
|
||||
break;
|
||||
}
|
||||
|
||||
thumbnails = jv_array_append(thumbnails,
|
||||
JV_OBJECT(jv_string("width"), jv_number(item->twidth),
|
||||
jv_string("height"), jv_number(item->theight),
|
||||
jv_string("flip"), jv_number(item->tflip),
|
||||
jv_string("format"), jv_string(format)));
|
||||
jv to = JV_OBJECT(
|
||||
jv_string("width"), jv_number(item->twidth),
|
||||
jv_string("height"), jv_number(item->theight),
|
||||
jv_string("flip"), jv_number(item->tflip),
|
||||
jv_string("format"), jv_string(format));
|
||||
|
||||
if (item->tformat == LIBRAW_INTERNAL_THUMBNAIL_JPEG &&
|
||||
item->toffset > 0 &&
|
||||
(size_t) item->toffset + item->tlength <= len) {
|
||||
to = jv_set(to, jv_string("JPEG"),
|
||||
parse_jpeg(jv_object(), p + item->toffset, item->tlength));
|
||||
}
|
||||
|
||||
thumbnails = jv_array_append(thumbnails, to);
|
||||
}
|
||||
|
||||
libraw_close(iprc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user