39 char confname[200] = { 0 };
44 gboolean found_duplicate =
FALSE;
47 int num_items =
dt_conf_get_int(
"plugins/lighttable/recentcollect/num_items");
48 for(
int k = 0;
k < num_items;
k++)
50 snprintf(confname,
sizeof(confname),
"plugins/lighttable/recentcollect/line%1d",
k);
53 if(!strcmp(line, buf))
56 found_duplicate =
TRUE;
64 const int max_items = CLAMP(
dt_conf_get_int(
"plugins/lighttable/recentcollect/max_items"), 1,
66 int shifted_index =
MIN(num_items - (found_duplicate ? 1 : 0), max_items);
67 for(
int k = num_items - 1;
k > -1;
k--)
72 snprintf(confname,
sizeof(confname),
"plugins/lighttable/recentcollect/line%1d",
k);
74 snprintf(confname,
sizeof(confname),
"plugins/lighttable/recentcollect/pos%1d",
k);
84 if(shifted_index >= 0 && shifted_index < max_items)
86 snprintf(confname,
sizeof(confname),
"plugins/lighttable/recentcollect/line%1d", shifted_index);
88 snprintf(confname,
sizeof(confname),
"plugins/lighttable/recentcollect/pos%1d", shifted_index);
99 num_items += found_duplicate ? 0 : 1;
100 dt_conf_set_int(
"plugins/lighttable/recentcollect/num_items", CLAMP(num_items, 1, max_items));
void dt_collection_set_recents_handler(dt_collection_recents_handler_t handler)
int dt_collection_serialize(char *buf, int bufsize)
#define NUM_LAST_COLLECTIONS
static void _update_recentcollections()
void dt_collection_gui_register_handlers(void)
gchar * dt_conf_get_string(const char *name)
Read the stored string for name as a private copy.
void dt_conf_set_int(const char *name, int val)
int dt_conf_get_int(const char *name)
Integer for name, clamped to the bounds declared in the XML.
void dt_conf_set_string(const char *name, const char *val)
const char * dt_conf_get_string_const(const char *name)
Borrow the stored string for name without copying it.
float *const restrict const size_t k
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.