static void export_button_clicked (GtkWidget *widget, gpointer user_data) { char style[128]; // Let's get the max dimension restriction if any... // TODO: pass the relevant values directly, not using the conf ... int max_width = dt_conf_get_int ("plugins/lighttable/export/width"); int max_height = dt_conf_get_int ("plugins/lighttable/export/height"); char *format_name = dt_conf_get_string("plugins/lighttable/export/format_name"); char *storage_name = dt_conf_get_string("plugins/lighttable/export/storage_name"); int format_index = dt_imageio_get_index_of_format(dt_imageio_get_format_by_name(format_name)); int storage_index = dt_imageio_get_index_of_storage(dt_imageio_get_storage_by_name(storage_name)); g_free(format_name); g_free(storage_name); gboolean high_quality = dt_conf_get_bool("plugins/lighttable/export/high_quality_processing"); char* tmp = dt_conf_get_string("plugins/lighttable/export/style"); if (tmp) { g_strlcpy(style, tmp, sizeof(style)); g_free(tmp); } int imgid = dt_view_get_image_to_act_on(); GList *list = NULL; if (imgid != -1) list = g_list_append (list, GINT_TO_POINTER(imgid)); else list = dt_collection_get_selected(darktable.collection, -1); dt_control_export(list, max_width, max_height, format_index, storage_index, high_quality,style); }
static int selection_cb(lua_State *L) { GList *image = dt_collection_get_selected(darktable.collection, -1); if(lua_gettop(L) > 0) { GList * new_selection = NULL; luaL_checktype(L,-1,LUA_TTABLE); lua_pushnil(L); while (lua_next(L, -2) != 0) { /* uses 'key' (at index -2) and 'value' (at index -1) */ int imgid; luaA_to(L,dt_lua_image_t,&imgid,-1); new_selection = g_list_prepend(new_selection,GINT_TO_POINTER(imgid)); lua_pop(L,1); } new_selection = g_list_reverse(new_selection); dt_lua_unlock(true);// we need the gdk lock to update ui information dt_selection_clear(darktable.selection); dt_selection_select_list(darktable.selection,new_selection); dt_lua_lock(); g_list_free(new_selection); } lua_newtable(L); while(image) { luaA_push(L,dt_lua_image_t,&image->data); luaL_ref(L,-2); image = g_list_delete_link(image, image); } return 1; }
void enter(dt_view_t *self) { dt_print_t *prt=(dt_print_t*)self->data; /* scroll filmstrip to the first selected image */ GList *selected_images = dt_collection_get_selected(darktable.collection, 1); if(selected_images) { int imgid = GPOINTER_TO_INT(selected_images->data); prt->image_id = imgid; dt_view_filmstrip_scroll_to_image(darktable.view_manager, imgid, FALSE); } g_list_free(selected_images); _set_orientation(prt); dt_control_signal_connect(darktable.signals, DT_SIGNAL_DEVELOP_MIPMAP_UPDATED, G_CALLBACK(_print_mipmaps_updated_signal_callback), (gpointer)self); dt_control_signal_connect(darktable.signals, DT_SIGNAL_VIEWMANAGER_FILMSTRIP_ACTIVATE, G_CALLBACK(_view_print_filmstrip_activate_callback), self); gtk_widget_grab_focus(dt_ui_center(darktable.gui->ui)); // prefetch next few from first selected image on. dt_view_filmstrip_prefetch(); darktable.control->mouse_over_id = -1; dt_control_set_mouse_over_id(prt->image_id); }
void dt_control_match_similar(dt_similarity_t *data) { dt_job_t j; GList *selected = dt_collection_get_selected(darktable.collection); if(selected) { dt_control_match_similar_job_init(&j, (long int)selected->data, data); dt_control_add_job(darktable.control, &j); } else dt_control_log(_("select an image as target for search of similar images")); }
/* enumerator of selected images */ void dt_control_image_enumerator_job_selected_init(dt_control_image_enumerator_t *t) { GList *list = NULL; long int imgid = dt_view_get_image_to_act_on(); if(imgid < 0) { /* get sorted list of selected images */ t->index = dt_collection_get_selected(darktable.collection); } else { /* Create a list with only one image */ list = g_list_append (list, (gpointer)imgid); t->index = list; } }
// http://stackoverflow.com/questions/4631388/transparent-floating-gtkentry static gboolean _lib_tagging_tag_key_press(GtkWidget *entry, GdkEventKey *event, dt_lib_module_t *self) { dt_lib_tagging_t *d = (dt_lib_tagging_t*)self->data; switch(event->keyval) { case GDK_Escape: gtk_widget_destroy(d->floating_tag_window); return TRUE; case GDK_Tab: return TRUE; case GDK_Return: case GDK_KP_Enter: { const gchar *tag = gtk_entry_get_text(GTK_ENTRY(entry)); /* create new tag */ guint tid=0; dt_tag_new(tag, &tid); /* attach tag to images */ if(d->floating_tag_imgid > 0) // just a single image { dt_tag_attach(tid, d->floating_tag_imgid); dt_image_synch_xmp(d->floating_tag_imgid); } else // all selected images { GList *selected_images = g_list_first(dt_collection_get_selected(darktable.collection)); if(selected_images) { GList *iter = selected_images; do { int imgid = GPOINTER_TO_INT(iter->data); dt_tag_attach(tid, imgid); dt_image_synch_xmp(imgid); } while( (iter=g_list_next(iter)) !=NULL ); } g_list_free(selected_images); } update(self, 1); update(self, 0); gtk_widget_destroy(d->floating_tag_window); return TRUE; } } return FALSE; /* event not handled */ }
static void export_button_clicked (GtkWidget *widget, gpointer user_data) { char style[128]; // Let's get the max dimension restriction if any... // TODO: pass the relevant values directly, not using the conf ... int max_width = dt_conf_get_int ("plugins/lighttable/export/width"); int max_height = dt_conf_get_int ("plugins/lighttable/export/height"); int format_index = dt_conf_get_int ("plugins/lighttable/export/format"); int storage_index = dt_conf_get_int ("plugins/lighttable/export/storage"); gboolean high_quality = dt_conf_get_bool("plugins/lighttable/export/high_quality_processing"); char* tmp = dt_conf_get_string("plugins/lighttable/export/style"); if (tmp) { strncpy (style, tmp, 128); g_free(tmp); } dt_control_export(dt_collection_get_selected(darktable.collection),max_width, max_height, format_index, storage_index, high_quality,style); }
static int act_on_cb(lua_State *L) { int32_t imgid = dt_view_get_image_to_act_on(); lua_newtable(L); if(imgid != -1) { luaA_push(L,dt_lua_image_t,&imgid); luaL_ref(L,-2); return 1; } else { GList *image = dt_collection_get_selected(darktable.collection, -1); while(image) { luaA_push(L,dt_lua_image_t,&image->data); luaL_ref(L,-2); image = g_list_delete_link(image, image); } return 1; } }
static int lua_button_clicked_cb(lua_State* L) { lua_callback_data * data = lua_touserdata(L,1); dt_lua_module_entry_push(L,"lib",data->self->plugin_name); lua_getuservalue(L,-1); lua_getfield(L,-1,"callbacks"); lua_getfield(L,-1,data->key); lua_pushstring(L,data->key); GList *image = dt_collection_get_selected(darktable.collection, -1); lua_newtable(L); while(image) { luaA_push(L, dt_lua_image_t, &image->data); luaL_ref(L, -2); image = g_list_delete_link(image, image); } lua_call(L,2,0); return 0; }
const dt_selection_t *dt_selection_new() { dt_selection_t *s = g_malloc0(sizeof(dt_selection_t)); /* initialize the collection copy */ _selection_update_collection(NULL, (gpointer)s); /* initialize last_single_id based on current database */ s->last_single_id = -1; if(dt_collection_get_selected_count(darktable.collection) >= 1) { GList *selected_image = dt_collection_get_selected(darktable.collection, 1); s->last_single_id = GPOINTER_TO_INT(selected_image->data); g_list_free(selected_image); } /* setup signal handler for darktable collection update to update the internal collection of the selection */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_COLLECTION_CHANGED, G_CALLBACK(_selection_update_collection), (gpointer)s); return s; }
/* enumerator of selected images */ void dt_control_image_enumerator_job_selected_init(dt_control_image_enumerator_t *t) { /* get sorted list of selected images */ t->index = dt_collection_get_selected(darktable.collection); }