Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to permit group persistence #17795

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/common/grouping.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
#include "control/signal.h"
#include "gui/gtk.h"

#ifdef USE_LUA
#include "lua/call.h"
#include "lua/events.h"
#include "lua/image.h"
#endif

/** add an image to a group */
void dt_grouping_add_to_group(const dt_imgid_t group_id,
const dt_imgid_t image_id)
Expand All @@ -39,6 +45,16 @@ void dt_grouping_add_to_group(const dt_imgid_t group_id,
GList *imgs = NULL;
imgs = g_list_prepend(imgs, GINT_TO_POINTER(image_id));
DT_CONTROL_SIGNAL_RAISE(DT_SIGNAL_IMAGE_INFO_CHANGED, imgs);

#ifdef USE_LUA
dt_lua_async_call_alien(dt_lua_event_trigger_wrapper,
0, NULL, NULL,
LUA_ASYNC_TYPENAME, "const char*", "image-group-information-changed",
LUA_ASYNC_TYPENAME, "const char*", "add",
LUA_ASYNC_TYPENAME, "dt_lua_image_t", GINT_TO_POINTER(image_id),
LUA_ASYNC_TYPENAME, "dt_lua_image_t", GINT_TO_POINTER(group_id),
LUA_ASYNC_DONE);
#endif
}

/** remove an image from a group */
Expand Down Expand Up @@ -86,6 +102,15 @@ dt_imgid_t dt_grouping_remove_from_group(const dt_imgid_t image_id)
DT_DEBUG_SQLITE3_BIND_INT(stmt, 3, image_id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
#ifdef USE_LUA
dt_lua_async_call_alien(dt_lua_event_trigger_wrapper,
0, NULL, NULL,
LUA_ASYNC_TYPENAME, "const char*", "image-group-information-changed",
LUA_ASYNC_TYPENAME, "const char*", "remove-leader",
LUA_ASYNC_TYPENAME, "dt_lua_image_t", GINT_TO_POINTER(image_id),
LUA_ASYNC_TYPENAME, "dt_lua_image_t", GINT_TO_POINTER(new_group_id),
LUA_ASYNC_DONE);
#endif
}
else
{
Expand All @@ -104,6 +129,15 @@ dt_imgid_t dt_grouping_remove_from_group(const dt_imgid_t image_id)
imgs = g_list_prepend(imgs, GINT_TO_POINTER(image_id));
// refresh also the group leader which may be alone now
imgs = g_list_prepend(imgs, GINT_TO_POINTER(img_group_id));
#ifdef USE_LUA
dt_lua_async_call_alien(dt_lua_event_trigger_wrapper,
0, NULL, NULL,
LUA_ASYNC_TYPENAME, "const char*", "image-group-information-changed",
LUA_ASYNC_TYPENAME, "const char*", "remove",
LUA_ASYNC_TYPENAME, "dt_lua_image_t", GINT_TO_POINTER(image_id),
LUA_ASYNC_TYPENAME, "dt_lua_image_t", GINT_TO_POINTER(img_group_id),
LUA_ASYNC_DONE);
#endif
}
DT_CONTROL_SIGNAL_RAISE(DT_SIGNAL_IMAGE_INFO_CHANGED, imgs);

Expand Down Expand Up @@ -136,6 +170,16 @@ dt_imgid_t dt_grouping_change_representative(const dt_imgid_t image_id)
sqlite3_finalize(stmt);
DT_CONTROL_SIGNAL_RAISE(DT_SIGNAL_IMAGE_INFO_CHANGED, imgs);

#ifdef USE_LUA
dt_lua_async_call_alien(dt_lua_event_trigger_wrapper,
0, NULL, NULL,
LUA_ASYNC_TYPENAME, "const char*", "image-group-information-changed",
LUA_ASYNC_TYPENAME, "const char*", "leader-change",
LUA_ASYNC_TYPENAME, "dt_lua_image_t", GINT_TO_POINTER(image_id),
LUA_ASYNC_TYPENAME, "dt_lua_image_t", GINT_TO_POINTER(image_id),
LUA_ASYNC_DONE);
#endif

return image_id;
}

Expand Down
4 changes: 2 additions & 2 deletions src/common/tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ GList *dt_tag_get_list(const dt_imgid_t imgid)

gboolean omit_tag_hierarchy = dt_conf_get_bool("omit_tag_hierarchy");

const uint32_t count = dt_tag_get_attached(imgid, &taglist, TRUE);
const uint32_t count = dt_tag_get_attached(imgid, &taglist, FALSE);

if(count < 1)
return NULL;
Expand Down Expand Up @@ -938,7 +938,7 @@ GList *dt_tag_get_hierarchical(const dt_imgid_t imgid)
GList *taglist = NULL;
GList *tags = NULL;

const uint32_t count = dt_tag_get_attached(imgid, &taglist, TRUE);
const uint32_t count = dt_tag_get_attached(imgid, &taglist, FALSE);

if(count < 1)
return NULL;
Expand Down
5 changes: 5 additions & 0 deletions src/lua/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,11 @@ int dt_lua_init_events(lua_State *L)
lua_pushcfunction(L, dt_lua_event_multiinstance_trigger);
dt_lua_event_add(L, "pixelpipe-processing-complete");

lua_pushcfunction(L, dt_lua_event_multiinstance_register);
lua_pushcfunction(L, dt_lua_event_multiinstance_destroy);
lua_pushcfunction(L, dt_lua_event_multiinstance_trigger);
dt_lua_event_add(L, "image-group-information-changed");

return 0;
}
// clang-format off
Expand Down
Loading