static void _jump_to() { int32_t imgid = dt_control_get_mouse_over_id(); if(imgid == -1) { sqlite3_stmt *stmt; DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "select imgid from selected_images", -1, &stmt, NULL); if(sqlite3_step(stmt) == SQLITE_ROW) imgid = sqlite3_column_int(stmt, 0); sqlite3_finalize(stmt); } if(imgid != -1) { char path[512]; const dt_image_t *img = dt_image_cache_read_get(darktable.image_cache, imgid); dt_image_film_roll_directory(img, path, sizeof(path)); dt_image_cache_read_release(darktable.image_cache, img); char collect[1024]; snprintf(collect, sizeof(collect), "1:0:0:%s$", path); dt_collection_deserialize(collect); } }
static void button_pressed (GtkButton *button, gpointer user_data) { dt_lib_module_t *self = (dt_lib_module_t *)user_data; dt_lib_recentcollect_t *d = (dt_lib_recentcollect_t *) self->data; // deserialize this button's preset int n = -1; for(int k=0; k<NUM_LINES; k++) { if(button == GTK_BUTTON(d->item[k].button)) { n = k; break; } } if(n < 0) return; char confname[200]; snprintf(confname, 200, "plugins/lighttable/recentcollect/line%1d", n); gchar *line = dt_conf_get_string(confname); if(line) { dt_collection_deserialize(line); g_free(line); // position will be updated when the list of recent collections is. // that way it'll also catch cases when this is triggered by a signal, // not only our button press here. } }
static gboolean _goto_previous(GtkAccelGroup *accel_group, GObject *acceleratable, guint keyval, GdkModifierType modifier, gpointer data) { gchar *line = dt_conf_get_string("plugins/lighttable/recentcollect/line1"); if(line) { dt_collection_deserialize(line); g_free(line); } return TRUE; }
static int32_t _generic_dt_control_fileop_images_job_run(dt_job_t *job, int32_t (*fileop_callback)(const int32_t, const int32_t), const char *desc, const char *desc_pl) { dt_control_image_enumerator_t *t1 = (dt_control_image_enumerator_t *)job->param; GList *t = t1->index; int total = g_list_length(t); char message[512]= {0}; double fraction = 0; gchar *newdir = (gchar *)job->user_data; /* create a cancellable bgjob ui template */ g_snprintf(message, 512, ngettext(desc, desc_pl, total), total); const guint *jid = dt_control_backgroundjobs_create(darktable.control, 0, message); dt_control_backgroundjobs_set_cancellable(darktable.control, jid, job); // create new film roll for the destination directory dt_film_t new_film; const int32_t film_id = dt_film_new(&new_film, newdir); g_free(newdir); if (film_id <= 0) { dt_control_log(_("failed to create film roll for destination directory, aborting move..")); dt_control_backgroundjobs_destroy(darktable.control, jid); return -1; } while(t && dt_control_job_get_state(job) != DT_JOB_STATE_CANCELLED) { fileop_callback(GPOINTER_TO_INT(t->data), film_id); t = g_list_delete_link(t, t); fraction+=1.0/total; dt_control_backgroundjobs_progress(darktable.control, jid, fraction); } char collect[1024]; snprintf(collect, 1024, "1:0:0:%s$", new_film.dirname); dt_collection_deserialize(collect); dt_control_backgroundjobs_destroy(darktable.control, jid); dt_film_remove_empty(); dt_control_signal_raise(darktable.signals, DT_SIGNAL_FILMROLLS_CHANGED); dt_control_queue_redraw_center(); return 0; }