本文整理汇总了C++中dt_control_signal_raise函数的典型用法代码示例。如果您正苦于以下问题:C++ dt_control_signal_raise函数的具体用法?C++ dt_control_signal_raise怎么用?C++ dt_control_signal_raise使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dt_control_signal_raise函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dt_film_remove
// This is basically the same as dt_image_remove() from common/image.c.
// It just does the iteration over all images in the SQL statement
void dt_film_remove(const int id)
{
sqlite3_stmt *stmt;
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"update tagxtag set count = count - 1 where "
"(id2 in (select tagid from tagged_images where imgid in "
"(select id from images where film_id = ?1))) or (id1 in "
"(select tagid from tagged_images where imgid in "
"(select id from images where film_id = ?1)))", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from tagged_images where imgid in "
"(select id from images where film_id = ?1)", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from history where imgid in "
"(select id from images where film_id = ?1)", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from color_labels where imgid in "
"(select id from images where film_id = ?1)", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from meta_data where id in "
"(select id from images where film_id = ?1)", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from selected_images where imgid in "
"(select id from images where film_id = ?1)", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"select id from images where film_id = ?1", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
while(sqlite3_step(stmt) == SQLITE_ROW)
{
const uint32_t imgid = sqlite3_column_int(stmt, 0);
dt_mipmap_cache_remove(darktable.mipmap_cache, imgid);
dt_image_cache_remove (darktable.image_cache, imgid);
}
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from images where id in "
"(select id from images where film_id = ?1)", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"delete from film_rolls where id = ?1", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
// dt_control_update_recent_films();
dt_control_signal_raise(darktable.signals , DT_SIGNAL_FILMROLLS_CHANGED);
}
示例2: dt_imageio_insert_storage
void dt_imageio_insert_storage(dt_imageio_module_storage_t* storage)
{
darktable.imageio->plugins_storage = g_list_insert_sorted(darktable.imageio->plugins_storage, storage, dt_imageio_sort_modules_storage);
dt_control_signal_raise(darktable.signals,DT_SIGNAL_IMAGEIO_STORAGE_CHANGE);
}
示例3: dt_control_queue_redraw_center
void dt_control_queue_redraw_center()
{
dt_control_signal_raise(darktable.signals, DT_SIGNAL_CONTROL_REDRAW_CENTER);
}
示例4: delete_button_clicked
static void
delete_button_clicked (GtkButton *button, gpointer user_data)
{
dt_lib_module_t *self = (dt_lib_module_t *)user_data;
dt_lib_tagging_t *d = (dt_lib_tagging_t *)self->data;
int res = GTK_RESPONSE_YES;
guint tagid;
GtkTreeIter iter;
GtkTreeModel *model = NULL;
GtkTreeView *view = d->related;
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
if(!gtk_tree_selection_get_selected(selection, &model, &iter)) return;
gtk_tree_model_get (model, &iter,
DT_LIB_TAGGING_COL_ID, &tagid,
-1);
// First check how many images are affected by the remove
int count = dt_tag_remove(tagid,FALSE);
if( count > 0 && dt_conf_get_bool("plugins/lighttable/tagging/ask_before_delete_tag") )
{
GtkWidget *dialog;
GtkWidget *win = dt_ui_main_window(darktable.gui->ui);
gchar *tagname=dt_tag_get_name(tagid);
dialog = gtk_message_dialog_new(GTK_WINDOW(win),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
ngettext("do you really want to delete the tag `%s'?\n%d image is assigned this tag!",
"do you really want to delete the tag `%s'?\n%d images are assigned this tag!", count),
tagname,count);
gtk_window_set_title(GTK_WINDOW(dialog), _("delete tag?"));
res = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
free(tagname);
}
if(res != GTK_RESPONSE_YES) return;
GList *tagged_images = NULL;
sqlite3_stmt *stmt;
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "select imgid from tagged_images where tagid=?1", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, tagid);
while(sqlite3_step(stmt) == SQLITE_ROW)
{
tagged_images = g_list_append(tagged_images, GINT_TO_POINTER(sqlite3_column_int(stmt, 0)));
}
sqlite3_finalize(stmt);
dt_tag_remove(tagid,TRUE);
GList *list_iter;
if((list_iter = g_list_first(tagged_images)) != NULL)
{
do
{
dt_image_synch_xmp(GPOINTER_TO_INT(list_iter->data));
}
while((list_iter=g_list_next(list_iter)) != NULL);
}
g_list_free(g_list_first(tagged_images));
update(self, 0);
update(self, 1);
dt_control_signal_raise(darktable.signals, DT_SIGNAL_TAG_CHANGED);
}
示例5: gui_init
void gui_init(dt_lib_module_t *self)
{
/* initialize ui widgets */
dt_lib_keywords_t *d = (dt_lib_keywords_t *)g_malloc(sizeof(dt_lib_keywords_t));
memset(d,0,sizeof(dt_lib_keywords_t));
self->data = (void *)d;
self->widget = gtk_vbox_new(FALSE, 5);
/* Create a new scrolled window, with scrollbars only if needed */
GtkWidget *scrolled_window;
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
/* add the treeview to show hirarchy tags*/
GtkCellRenderer *renderer;
d->view = GTK_TREE_VIEW (gtk_tree_view_new());
gtk_widget_set_size_request(GTK_WIDGET(d->view), -1, 300);
gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(d->view));
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes(d->view,
-1,
"",
renderer,
"text", 0,
NULL);
gtk_tree_view_set_headers_visible(d->view, FALSE);
/* setup dnd source and destination within treeview */
static const GtkTargetEntry dnd_target = { "keywords-reorganize",
GTK_TARGET_SAME_WIDGET, 0
};
gtk_tree_view_enable_model_drag_source(d->view,
GDK_BUTTON1_MASK,
&dnd_target, 1, GDK_ACTION_MOVE);
gtk_tree_view_enable_model_drag_dest(d->view, &dnd_target, 1, GDK_ACTION_MOVE);
/* setup drag and drop signals */
g_signal_connect(G_OBJECT(d->view),"drag-data-received",
G_CALLBACK(_lib_keywords_drag_data_received_callback),
self);
g_signal_connect(G_OBJECT(d->view),"drag-data-get",
G_CALLBACK(_lib_keywords_drag_data_get_callback),
self);
/* add callback when keyword is activated */
g_signal_connect(G_OBJECT(d->view), "row-activated",
G_CALLBACK(_lib_keywords_add_collection_rule), self);
gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(scrolled_window), TRUE, TRUE, 0);
gtk_widget_show_all(GTK_WIDGET(d->view));
dt_control_signal_connect(darktable.signals,
DT_SIGNAL_TAG_CHANGED,
G_CALLBACK(_lib_tag_gui_update),
self);
/* raise signal of tags change to refresh keywords tree */
dt_control_signal_raise(darktable.signals, DT_SIGNAL_TAG_CHANGED);
}
示例6: dt_styles_update
void dt_styles_update(const char *name, const char *newname, const char *newdescription, GList *filter,
int imgid, GList *update)
{
sqlite3_stmt *stmt;
int id = 0;
gchar *desc = NULL;
id = dt_styles_get_id_by_name(name);
if(id == 0) return;
desc = dt_styles_get_description(name);
if((g_strcmp0(name, newname)) || (g_strcmp0(desc, newdescription)))
{
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"UPDATE data.styles SET name=?1, description=?2 WHERE id=?3", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_TEXT(stmt, 1, newname, -1, SQLITE_STATIC);
DT_DEBUG_SQLITE3_BIND_TEXT(stmt, 2, newdescription, -1, SQLITE_STATIC);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 3, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
if(filter)
{
GList *list = filter;
char tmp[64];
char include[2048] = { 0 };
g_strlcat(include, "num NOT IN (", sizeof(include));
do
{
if(list != g_list_first(list)) g_strlcat(include, ",", sizeof(include));
snprintf(tmp, sizeof(tmp), "%d", GPOINTER_TO_INT(list->data));
g_strlcat(include, tmp, sizeof(include));
} while((list = g_list_next(list)));
g_strlcat(include, ")", sizeof(include));
char query[4096] = { 0 };
snprintf(query, sizeof(query), "DELETE FROM data.style_items WHERE styleid=?1 AND %s", include);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), query, -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
_dt_style_update_from_image(id, imgid, filter, update);
_dt_style_cleanup_multi_instance(id);
/* backup style to disk */
char stylesdir[PATH_MAX] = { 0 };
dt_loc_get_user_config_dir(stylesdir, sizeof(stylesdir));
g_strlcat(stylesdir, "/styles", sizeof(stylesdir));
g_mkdir_with_parents(stylesdir, 00755);
dt_styles_save_to_file(newname, stylesdir, TRUE);
/* delete old accelerator and create a new one */
// TODO: should better use dt_accel_rename_global() to keep the old accel_key untouched, but it seems to be
// buggy
if(g_strcmp0(name, newname))
{
char tmp_accel[1024];
snprintf(tmp_accel, sizeof(tmp_accel), C_("accel", "styles/apply %s"), name);
dt_accel_deregister_global(tmp_accel);
gchar *tmp_name = g_strdup(newname); // freed by _destroy_style_shortcut_callback
snprintf(tmp_accel, sizeof(tmp_accel), C_("accel", "styles/apply %s"), newname);
dt_accel_register_global(tmp_accel, 0, 0);
GClosure *closure;
closure = g_cclosure_new(G_CALLBACK(_apply_style_shortcut_callback), tmp_name,
_destroy_style_shortcut_callback);
dt_accel_connect_global(tmp_accel, closure);
}
dt_control_signal_raise(darktable.signals, DT_SIGNAL_STYLE_CHANGED);
g_free(desc);
}
示例7: dt_styles_apply_to_image
void dt_styles_apply_to_image(const char *name, gboolean duplicate, int32_t imgid)
{
int id = 0;
sqlite3_stmt *stmt;
int32_t newimgid;
if((id = dt_styles_get_id_by_name(name)) != 0)
{
/* check if we should make a duplicate before applying style */
if(duplicate)
{
newimgid = dt_image_duplicate(imgid);
if(newimgid != -1) dt_history_copy_and_paste_on_image(imgid, newimgid, FALSE, NULL);
}
else
newimgid = imgid;
/* merge onto history stack, let's find history offest in destination image */
/* first trim the stack to get rid of whatever is above the selected entry */
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"DELETE FROM main.history WHERE imgid = ?1 AND num >= (SELECT history_end "
"FROM main.images WHERE id = imgid)", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, newimgid);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
/* in sqlite ROWID starts at 1, while our num column starts at 0 */
int32_t offs = -1;
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"SELECT IFNULL(MAX(num), -1) FROM main.history WHERE imgid = ?1", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, newimgid);
if(sqlite3_step(stmt) == SQLITE_ROW) offs = sqlite3_column_int(stmt, 0);
sqlite3_finalize(stmt);
/* delete all items from the temp styles_items, this table is used only to get a ROWNUM of the results */
DT_DEBUG_SQLITE3_EXEC(dt_database_get(darktable.db), "DELETE FROM memory.style_items", NULL, NULL, NULL);
/* copy history items from styles onto temp table */
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "INSERT INTO memory.style_items SELECT * FROM "
"data.style_items WHERE styleid=?1 ORDER BY "
"multi_priority DESC",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
/* copy the style items into the history */
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"INSERT INTO main.history "
"(imgid,num,module,operation,op_params,enabled,blendop_params,blendop_"
"version,multi_priority,multi_name) SELECT "
"?1,?2+rowid,module,operation,op_params,enabled,blendop_params,blendop_"
"version,multi_priority,multi_name FROM memory.style_items",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, newimgid);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, offs);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
/* always make the whole stack active */
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"UPDATE main.images SET history_end = (SELECT MAX(num) + 1 FROM main.history "
"WHERE imgid = ?1) WHERE id = ?1",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, newimgid);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
/* add tag */
guint tagid = 0;
gchar ntag[512] = { 0 };
g_snprintf(ntag, sizeof(ntag), "darktable|style|%s", name);
if(dt_tag_new(ntag, &tagid)) dt_tag_attach(tagid, newimgid);
if(dt_tag_new("darktable|changed", &tagid)) dt_tag_attach(tagid, newimgid);
/* if current image in develop reload history */
if(dt_dev_is_current_image(darktable.develop, newimgid))
{
dt_dev_reload_history_items(darktable.develop);
dt_dev_modulegroups_set(darktable.develop, dt_dev_modulegroups_get(darktable.develop));
}
/* update xmp file */
dt_image_synch_xmp(newimgid);
/* remove old obsolete thumbnails */
dt_mipmap_cache_remove(darktable.mipmap_cache, newimgid);
/* if we have created a duplicate, reset collected images */
if(duplicate) dt_control_signal_raise(darktable.signals, DT_SIGNAL_COLLECTION_CHANGED);
/* redraw center view to update visible mipmaps */
dt_control_queue_redraw_center();
}
}
示例8: dt_film_import1
void dt_film_import1(dt_film_t *film)
{
gboolean recursive = dt_conf_get_bool("ui_last/import_recursive");
/* first of all gather all images to import */
GList *images = NULL;
images = _film_recursive_get_files(film->dirname, recursive, &images);
if(g_list_length(images) == 0)
{
dt_control_log(_("no supported images were found to be imported"));
return;
}
/* we got ourself a list of images, lets sort and start import */
images = g_list_sort(images,(GCompareFunc)_film_filename_cmp);
/* let's start import of images */
gchar message[512] = {0};
double fraction = 0;
uint32_t total = g_list_length(images);
g_snprintf(message, sizeof(message) - 1,
ngettext("importing %d image","importing %d images", total), total);
const guint *jid = dt_control_backgroundjobs_create(darktable.control, 0, message);
/* loop thru the images and import to current film roll */
dt_film_t *cfr = film;
GList *image = g_list_first(images);
do
{
gchar *cdn = g_path_get_dirname((const gchar *)image->data);
/* check if we need to initialize a new filmroll */
if(!cfr || g_strcmp0(cfr->dirname, cdn) != 0)
{
#if GLIB_CHECK_VERSION (2, 26, 0)
if(cfr && cfr->dir)
{
/* check if we can find a gpx data file to be auto applied
to images in the jsut imported filmroll */
g_dir_rewind(cfr->dir);
const gchar *dfn = NULL;
while ((dfn = g_dir_read_name(cfr->dir)) != NULL)
{
/* check if we have a gpx to be auto applied to filmroll */
if(strcmp(dfn+strlen(dfn)-4,".gpx") == 0 ||
strcmp(dfn+strlen(dfn)-4,".GPX") == 0)
{
gchar *gpx_file = g_build_path (G_DIR_SEPARATOR_S, cfr->dirname, dfn, NULL);
dt_control_gpx_apply(gpx_file, cfr->id, dt_conf_get_string("plugins/lighttable/geotagging/tz"));
g_free(gpx_file);
}
}
}
#endif
/* cleanup previously imported filmroll*/
if(cfr && cfr!=film)
{
if(dt_film_is_empty(cfr->id))
{
dt_film_remove(cfr->id);
}
dt_film_cleanup(cfr);
g_free(cfr);
cfr = NULL;
}
/* initialize and create a new film to import to */
cfr = g_malloc(sizeof(dt_film_t));
dt_film_init(cfr);
dt_film_new(cfr, cdn);
}
/* import image */
dt_image_import(cfr->id, (const gchar *)image->data, FALSE);
fraction+=1.0/total;
dt_control_backgroundjobs_progress(darktable.control, jid, fraction);
}
while( (image = g_list_next(image)) != NULL);
// only redraw at the end, to not spam the cpu with exposure events
dt_control_queue_redraw_center();
dt_control_signal_raise(darktable.signals,DT_SIGNAL_TAG_CHANGED);
dt_control_backgroundjobs_destroy(darktable.control, jid);
dt_control_signal_raise(darktable.signals , DT_SIGNAL_FILMROLLS_IMPORTED,film->id);
#if GLIB_CHECK_VERSION (2, 26, 0)
if(cfr && cfr->dir)
{
/* check if we can find a gpx data file to be auto applied
to images in the just imported filmroll */
g_dir_rewind(cfr->dir);
const gchar *dfn = NULL;
while ((dfn = g_dir_read_name(cfr->dir)) != NULL)
{
/* check if we have a gpx to be auto applied to filmroll */
//.........这里部分代码省略.........
示例9: dt_film_remove
// This is basically the same as dt_image_remove() from common/image.c.
// It just does the iteration over all images in the SQL statement
void dt_film_remove(const int id)
{
// only allowed if local copies have their original accessible
sqlite3_stmt *stmt;
gboolean remove_ok = TRUE;
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "SELECT id FROM main.images WHERE film_id = ?1", -1,
&stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
while(sqlite3_step(stmt) == SQLITE_ROW)
{
int imgid = sqlite3_column_int(stmt, 0);
if(!dt_image_safe_remove(imgid))
{
remove_ok = FALSE;
break;
}
}
sqlite3_finalize(stmt);
if(!remove_ok)
{
dt_control_log(_("cannot remove film roll having local copies with non accessible originals"));
return;
}
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "DELETE FROM main.tagged_images WHERE imgid IN "
"(SELECT id FROM main.images WHERE film_id = ?1)",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "DELETE FROM main.history WHERE imgid IN "
"(SELECT id FROM main.images WHERE film_id = ?1)",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "DELETE FROM main.masks_history WHERE imgid IN "
"(SELECT id FROM main.images WHERE film_id = ?1)",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "DELETE FROM main.color_labels WHERE imgid IN "
"(SELECT id FROM main.images WHERE film_id = ?1)",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "DELETE FROM main.meta_data WHERE id IN "
"(SELECT id FROM main.images WHERE film_id = ?1)",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "DELETE FROM main.selected_images WHERE imgid IN "
"(SELECT id FROM main.images WHERE film_id = ?1)",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "SELECT id FROM main.images WHERE film_id = ?1", -1,
&stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
while(sqlite3_step(stmt) == SQLITE_ROW)
{
const uint32_t imgid = sqlite3_column_int(stmt, 0);
dt_image_local_copy_reset(imgid);
dt_mipmap_cache_remove(darktable.mipmap_cache, imgid);
dt_image_cache_remove(darktable.image_cache, imgid);
}
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "DELETE FROM main.images WHERE id IN "
"(SELECT id FROM main.images WHERE film_id = ?1)",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "DELETE FROM main.film_rolls WHERE id = ?1", -1,
&stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
// dt_control_update_recent_films();
dt_tag_update_used_tags();
dt_control_signal_raise(darktable.signals, DT_SIGNAL_FILMROLLS_CHANGED);
}
示例10: dt_image_import
//.........这里部分代码省略.........
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) fprintf(stderr, "sqlite3 error %d\n", rc);
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db),
"select id from images where film_id = ?1 and filename = ?2",
-1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, film_id);
DT_DEBUG_SQLITE3_BIND_TEXT(stmt, 2, imgfname, strlen(imgfname),
SQLITE_STATIC);
if(sqlite3_step(stmt) == SQLITE_ROW) id = sqlite3_column_int(stmt, 0);
sqlite3_finalize(stmt);
// Try to find out if this should be grouped already.
gchar *basename = g_strdup(imgfname);
gchar *cc2 = basename + strlen(basename);
for(; *cc2!='.'&&cc2>basename; cc2--);
*cc2='\0';
gchar *sql_pattern = g_strconcat(basename, ".%", NULL);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "select group_id from images where film_id = ?1 and filename like ?2 and id != ?3", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, film_id);
DT_DEBUG_SQLITE3_BIND_TEXT(stmt, 2, sql_pattern, -1, SQLITE_TRANSIENT);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 3, id);
int group_id;
if(sqlite3_step(stmt) == SQLITE_ROW) group_id = sqlite3_column_int(stmt, 0);
else group_id = id;
sqlite3_finalize(stmt);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "update images set group_id = ?1 where id = ?2", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, group_id);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
// printf("[image_import] importing `%s' to img id %d\n", imgfname, id);
// lock as shortly as possible:
const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, id);
dt_image_t *img = dt_image_cache_write_get(darktable.image_cache, cimg);
img->group_id = group_id;
// read dttags and exif for database queries!
(void) dt_exif_read(img, filename);
char dtfilename[DT_MAX_PATH_LEN];
g_strlcpy(dtfilename, filename, DT_MAX_PATH_LEN);
dt_image_path_append_version(id, dtfilename, DT_MAX_PATH_LEN);
char *c = dtfilename + strlen(dtfilename);
sprintf(c, ".xmp");
(void)dt_exif_xmp_read(img, dtfilename, 0);
// write through to db, but not to xmp.
dt_image_cache_write_release(darktable.image_cache, img, DT_IMAGE_CACHE_RELAXED);
dt_image_cache_read_release(darktable.image_cache, img);
// add a tag with the file extension
guint tagid = 0;
char tagname[512];
snprintf(tagname, 512, "darktable|format|%s", ext);
g_free(ext);
dt_tag_new(tagname, &tagid);
dt_tag_attach(tagid,id);
// Search for sidecar files and import them if found.
glob_t *globbuf = g_malloc(sizeof(glob_t));
// Add version wildcard
gchar *fname = g_strdup(filename);
gchar pattern[DT_MAX_PATH_LEN];
g_snprintf(pattern, DT_MAX_PATH_LEN, "%s", filename);
char *c1 = pattern + strlen(pattern);
while(*c1 != '.' && c1 > pattern) c1--;
snprintf(c1, pattern + DT_MAX_PATH_LEN - c1, "_*");
char *c2 = fname + strlen(fname);
while(*c2 != '.' && c2 > fname) c2--;
snprintf(c1+2, pattern + DT_MAX_PATH_LEN - c1 - 2, "%s.xmp", c2);
if (!glob(pattern, 0, NULL, globbuf))
{
for (int i=0; i < globbuf->gl_pathc; i++)
{
int newid = -1;
newid = dt_image_duplicate(id);
const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, newid);
dt_image_t *img = dt_image_cache_write_get(darktable.image_cache, cimg);
(void)dt_exif_xmp_read(img, globbuf->gl_pathv[i], 0);
dt_image_cache_write_release(darktable.image_cache, img, DT_IMAGE_CACHE_RELAXED);
dt_image_cache_read_release(darktable.image_cache, img);
}
globfree(globbuf);
}
g_free(imgfname);
g_free(fname);
g_free(basename);
g_free(sql_pattern);
g_free(globbuf);
dt_control_signal_raise(darktable.signals,DT_SIGNAL_IMAGE_IMPORT,id);
return id;
}
示例11: async_redraw
static gboolean async_redraw(gpointer data)
{
dt_control_signal_raise(darktable.signals, DT_SIGNAL_FILMROLLS_CHANGED); // just for good measure
dt_control_queue_redraw();
return false;
}
示例12: dt_view_manager_switch
//.........这里部分代码省略.........
{
dt_lib_module_t *plugin = (dt_lib_module_t *)(plugins->data);
if( plugin->views() & nv->view(v) )
{
/* module should be in this view, lets initialize */
plugin->gui_init(plugin);
/* try get the module expander */
GtkWidget *w = NULL;
w = dt_lib_gui_get_expander(plugin);
if(plugin->connect_key_accels)
plugin->connect_key_accels(plugin);
dt_lib_connect_common_accels(plugin);
/* if we dont got an expander lets add the widget */
if (!w)
w = plugin->widget;
/* add module to it's container */
dt_ui_container_add_widget(darktable.gui->ui, plugin->container(), w);
}
/* lets get next plugin */
plugins = g_list_previous(plugins);
}
/* hide/show modules as last config */
plugins = g_list_last(darktable.lib->plugins);
while (plugins)
{
dt_lib_module_t *plugin = (dt_lib_module_t *)(plugins->data);
if(plugin->views() & nv->view(v))
{
/* set expanded if last mode was that */
char var[1024];
gboolean expanded = FALSE;
gboolean visible = dt_lib_is_visible(plugin);
if (plugin->expandable())
{
snprintf(var, 1024, "plugins/lighttable/%s/expanded", plugin->plugin_name);
expanded = dt_conf_get_bool(var);
/* show expander if visible */
if(visible)
{
gtk_widget_show_all(GTK_WIDGET(plugin->expander));
// gtk_widget_show_all(plugin->widget);
}
else
{
gtk_widget_hide(GTK_WIDGET(plugin->expander));
// gtk_widget_hide_all(plugin->widget);
}
dt_lib_gui_set_expanded(plugin, expanded);
}
else
{
/* show/hide plugin widget depending on expanded flag or if plugin
not is expandeable() */
if(visible)
gtk_widget_show_all(plugin->widget);
else
gtk_widget_hide_all(plugin->widget);
}
}
/* lets get next plugin */
plugins = g_list_previous(plugins);
}
/* enter view. crucially, do this before initing the plugins below,
as e.g. modulegroups requires the dr stuff to be inited. */
if(newv >= 0 && nv->enter) nv->enter(nv);
if(newv >= 0 && nv->connect_key_accels)
nv->connect_key_accels(nv);
/* raise view changed signal */
dt_control_signal_raise(darktable.signals, DT_SIGNAL_VIEWMANAGER_VIEW_CHANGED);
/* add endmarkers to left and right center containers */
GtkWidget *endmarker = gtk_drawing_area_new();
dt_ui_container_add_widget(darktable.gui->ui, DT_UI_CONTAINER_PANEL_LEFT_CENTER, endmarker);
g_signal_connect (G_OBJECT (endmarker), "expose-event",
G_CALLBACK (dt_control_expose_endmarker), 0);
gtk_widget_set_size_request(endmarker, -1, 50);
gtk_widget_show(endmarker);
endmarker = gtk_drawing_area_new();
dt_ui_container_add_widget(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER, endmarker);
g_signal_connect (G_OBJECT (endmarker), "expose-event",
G_CALLBACK (dt_control_expose_endmarker), (gpointer)1);
gtk_widget_set_size_request(endmarker, -1, 50);
gtk_widget_show(endmarker);
}
return error;
}
示例13: dt_control_delete_images_job_run
//.........这里部分代码省略.........
int duplicates = 0;
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid);
if(sqlite3_step(stmt) == SQLITE_ROW)
duplicates = sqlite3_column_int(stmt, 0);
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
// remove from disk:
if(duplicates == 1)
{
// there are no further duplicates so we can remove the source data file
(void)g_unlink(filename);
dt_image_remove(imgid);
// all sidecar files - including left-overs - can be deleted;
// left-overs can result when previously duplicates have been REMOVED;
// no need to keep them as the source data file is gone.
const int len = DT_MAX_PATH_LEN + 30;
gchar pattern[len];
// NULL terminated list of glob patterns; should include "" and can be extended if needed
static const gchar *glob_patterns[] = { "", "_[0-9][0-9]", "_[0-9][0-9][0-9]", "_[0-9][0-9][0-9][0-9]", NULL };
const gchar **glob_pattern = glob_patterns;
GList *files = NULL;
while(*glob_pattern)
{
snprintf(pattern, len, "%s", filename);
gchar *c1 = pattern + strlen(pattern);
while(*c1 != '.' && c1 > pattern) c1--;
snprintf(c1, pattern + len - c1, "%s", *glob_pattern);
const gchar *c2 = filename + strlen(filename);
while(*c2 != '.' && c2 > filename) c2--;
snprintf(c1+strlen(*glob_pattern), pattern + len - c1 - strlen(*glob_pattern), "%s.xmp", c2);
#ifdef __WIN32__
WIN32_FIND_DATA data;
HANDLE handle = FindFirstFile(pattern, &data);
if(handle != INVALID_HANDLE_VALUE)
{
do
files = g_list_append(files, g_strdup(data.cFileName));
while(FindNextFile(handle, &data));
}
#else
glob_t globbuf;
if(!glob(pattern, 0, NULL, &globbuf))
{
for(size_t i=0; i < globbuf.gl_pathc; i++)
files = g_list_append(files, g_strdup(globbuf.gl_pathv[i]));
globfree(&globbuf);
}
#endif
glob_pattern++;
}
GList *file_iter = g_list_first(files);
while(file_iter != NULL)
{
(void)g_unlink(file_iter->data);
file_iter = g_list_next(file_iter);
}
g_list_free_full(files, g_free);
}
else
{
// don't remove the actual source data if there are further duplicates using it;
// just delete the xmp file of the duplicate selected.
dt_image_path_append_version(imgid, filename, DT_MAX_PATH_LEN);
char *c = filename + strlen(filename);
sprintf(c, ".xmp");
dt_image_remove(imgid);
(void)g_unlink(filename);
}
t = g_list_delete_link(t, t);
fraction=1.0/total;
dt_control_backgroundjobs_progress(darktable.control, jid, fraction);
}
sqlite3_finalize(stmt);
char *imgname;
while(list)
{
imgname = (char *)list->data;
dt_image_synch_all_xmp(imgname);
list = g_list_delete_link(list, list);
}
g_list_free(list);
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;
}
示例14: dt_control_remove_images_job_run
int32_t dt_control_remove_images_job_run(dt_job_t *job)
{
int imgid = -1;
dt_control_image_enumerator_t *t1 = (dt_control_image_enumerator_t *)job->param;
GList *t = t1->index;
char *imgs = _get_image_list(t);
int total = g_list_length(t);
char message[512]= {0};
double fraction=0;
snprintf(message, 512, ngettext ("removing %d image", "removing %d images", total), total );
const guint *jid = dt_control_backgroundjobs_create(darktable.control, 0, message);
sqlite3_stmt *stmt = NULL;
// check that we can safely remove the image
gboolean remove_ok = TRUE;
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "SELECT id FROM images WHERE id IN (?2) AND flags&?1=?1", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, DT_IMAGE_LOCAL_COPY);
DT_DEBUG_SQLITE3_BIND_TEXT(stmt, 2, imgs, -1, SQLITE_STATIC);
while(sqlite3_step(stmt) == SQLITE_ROW)
{
int imgid = sqlite3_column_int(stmt, 0);
if (!dt_image_safe_remove(imgid))
{
remove_ok = FALSE;
break;
}
}
sqlite3_finalize(stmt);
if (!remove_ok)
{
dt_control_log(_("cannot remove local copy when the original file is not accessible."));
dt_control_backgroundjobs_destroy(darktable.control, jid);
free(imgs);
return 0;
}
// update remove status
_set_remove_flag(imgs);
dt_collection_update(darktable.collection);
// We need a list of files to regenerate .xmp files if there are duplicates
GList *list = _get_full_pathname(imgs);
free(imgs);
while(t)
{
imgid = GPOINTER_TO_INT(t->data);
dt_image_remove(imgid);
t = g_list_delete_link(t, t);
fraction=1.0/total;
dt_control_backgroundjobs_progress(darktable.control, jid, fraction);
}
char *imgname;
while(list)
{
imgname = (char *)list->data;
dt_image_synch_all_xmp(imgname);
list = g_list_delete_link(list, list);
}
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;
}
示例15: dt_lua_do_chunk
int dt_lua_do_chunk(lua_State *L,int nargs,int nresults)
{
lua_State * new_thread = lua_newthread(L);
lua_insert(L,-(nargs+2));
lua_xmove(L,new_thread,nargs+1);
int thread_result = lua_resume(new_thread, L,nargs);
do {
switch(thread_result) {
case LUA_OK:
if(darktable.gui!=NULL)
{
dt_lua_unlock(false);
dt_control_signal_raise(darktable.signals, DT_SIGNAL_FILMROLLS_CHANGED); // just for good measure
dt_control_queue_redraw();
dt_lua_lock();
}
if(nresults !=LUA_MULTRET) {
lua_settop(new_thread,nresults);
}
int result= lua_gettop(new_thread);
lua_pop(L,1);
lua_xmove(new_thread,L,result);
return result;
case LUA_YIELD:
{
if(lua_gettop(new_thread) == 0) {
lua_pushstring(new_thread,"no parameter passed to yield");
goto error;
}
yield_type type;
lua_pushcfunction(new_thread,protected_to_yield);
lua_pushvalue(new_thread,1);
thread_result = lua_pcall(new_thread,1,1,0);
if(thread_result!= LUA_OK)
goto error;
type = lua_tointeger(new_thread,-1);
lua_pop(new_thread,1);
switch(type) {
case WAIT_MS:
{
lua_pushcfunction(new_thread,protected_to_int);
lua_pushvalue(new_thread,2);
thread_result = lua_pcall(new_thread,1,1,0);
if(thread_result!= LUA_OK)
goto error;
int wait_time = lua_tointeger(new_thread,-1);
lua_pop(new_thread,1);
dt_lua_unlock(false);
g_usleep(wait_time*1000);
dt_lua_lock();
thread_result = lua_resume(new_thread,L,0);
break;
}
case FILE_READABLE:
{
lua_pushcfunction(new_thread,protected_to_userdata);
lua_pushvalue(new_thread,2);
lua_pushstring(new_thread,LUA_FILEHANDLE);
thread_result = lua_pcall(new_thread,2,1,0);
if(thread_result!= LUA_OK)
goto error;
luaL_Stream * stream = lua_touserdata(new_thread,-1);
lua_pop(new_thread,1);
int myfileno = fileno(stream->f);
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(myfileno,&fdset);
dt_lua_unlock(false);
select(myfileno+1,&fdset,NULL,NULL,0);
dt_lua_lock();
thread_result = lua_resume(new_thread,L,0);
break;
}
case RUN_COMMAND:
{
lua_pushcfunction(new_thread,protected_to_string);
lua_pushvalue(new_thread,2);
thread_result = lua_pcall(new_thread,1,1,0);
if(thread_result!= LUA_OK)
goto error;
const char* command = lua_tostring(new_thread,-1);
lua_pop(L,1);
dt_lua_unlock(false);
int result = system(command);
dt_lua_lock();
lua_pushinteger(L,result);
thread_result = lua_resume(new_thread,L,1);
break;
}
default:
lua_pushstring(new_thread,"program error, shouldn't happen");
goto error;
}
break;
}
default:
goto error;
}
}while(true);
error:
//.........这里部分代码省略.........