void gui_update(struct dt_iop_module_t *self) { dt_iop_module_t *module = (dt_iop_module_t *)self; dt_iop_colorchecker_gui_data_t *g = (dt_iop_colorchecker_gui_data_t *)self->gui_data; dt_iop_colorchecker_params_t *p = (dt_iop_colorchecker_params_t *)module->params; if(g->patch >= p->num_patches || g->patch < 0) return; if(dt_bauhaus_combobox_length(g->combobox_patch) != p->num_patches) { dt_bauhaus_combobox_clear(g->combobox_patch); char cboxentry[1024]; for(int k=0;k<p->num_patches;k++) { snprintf(cboxentry, sizeof(cboxentry), _("patch #%d"), k); dt_bauhaus_combobox_add(g->combobox_patch, cboxentry); } if(p->num_patches <= 24) dtgtk_drawing_area_set_aspect_ratio(g->area, 2.0/3.0); else dtgtk_drawing_area_set_aspect_ratio(g->area, 1.0); } dt_bauhaus_slider_set(g->scale_L, p->target_L[g->patch] - p->source_L[g->patch]); dt_bauhaus_slider_set(g->scale_a, p->target_a[g->patch] - p->source_a[g->patch]); dt_bauhaus_slider_set(g->scale_b, p->target_b[g->patch] - p->source_b[g->patch]); const float Cin = sqrtf( p->source_a[g->patch]*p->source_a[g->patch] + p->source_b[g->patch]*p->source_b[g->patch]); const float Cout = sqrtf( p->target_a[g->patch]*p->target_a[g->patch]+ p->target_b[g->patch]*p->target_b[g->patch]); dt_bauhaus_slider_set(g->scale_C, Cout-Cin); if(g->patch != g->drawn_patch) gtk_widget_queue_draw(g->area); }
static void refresh_watermarks(dt_iop_module_t *self) { dt_iop_watermark_gui_data_t *g = (dt_iop_watermark_gui_data_t *)self->gui_data; dt_iop_watermark_params_t *p = (dt_iop_watermark_params_t *)self->params; g_signal_handlers_block_by_func(g->watermarks, watermark_callback, self); // Clear combobox... dt_bauhaus_combobox_clear(g->watermarks); // check watermarkdir and update combo with entries... int count = 0; const gchar *d_name = NULL; gchar configdir[PATH_MAX] = { 0 }; gchar datadir[PATH_MAX] = { 0 }; gchar filename[PATH_MAX] = { 0 }; dt_loc_get_datadir(datadir, sizeof(datadir)); dt_loc_get_user_config_dir(configdir, sizeof(configdir)); g_strlcat(datadir, "/watermarks", sizeof(datadir)); g_strlcat(configdir, "/watermarks", sizeof(configdir)); /* read watermarks from datadir */ GDir *dir = g_dir_open(datadir, 0, NULL); if(dir) { while((d_name = g_dir_read_name(dir))) { snprintf(filename, sizeof(filename), "%s/%s", datadir, d_name); dt_bauhaus_combobox_add(g->watermarks, d_name); count++; } g_dir_close(dir); } /* read watermarks from user config dir*/ dir = g_dir_open(configdir, 0, NULL); if(dir) { while((d_name = g_dir_read_name(dir))) { snprintf(filename, sizeof(filename), "%s/%s", configdir, d_name); dt_bauhaus_combobox_add(g->watermarks, d_name); count++; } g_dir_close(dir); } _combo_box_set_active_text(g->watermarks, p->filename); g_signal_handlers_unblock_by_func(g->watermarks, watermark_callback, self); }
void gui_update (struct dt_iop_module_t *self) { dt_iop_module_t *module = (dt_iop_module_t *)self; self->request_color_pick = 0; self->color_picker_box[0] = self->color_picker_box[1] = .25f; self->color_picker_box[2] = self->color_picker_box[3] = .75f; self->color_picker_point[0] = self->color_picker_point[1] = 0.5f; dt_iop_temperature_gui_data_t *g = (dt_iop_temperature_gui_data_t *)self->gui_data; dt_iop_temperature_params_t *p = (dt_iop_temperature_params_t *)module->params; dt_iop_temperature_params_t *fp = (dt_iop_temperature_params_t *)module->default_params; float temp, tint, mul[3]; for(int k=0; k<3; k++) mul[k] = g->daylight_wb[k]/p->coeffs[k]; convert_rgb_to_k(mul, &temp, &tint); dt_bauhaus_slider_set(g->scale_r, p->coeffs[0]); dt_bauhaus_slider_set(g->scale_g, p->coeffs[1]); dt_bauhaus_slider_set(g->scale_b, p->coeffs[2]); dt_bauhaus_slider_set(g->scale_k, temp); dt_bauhaus_slider_set(g->scale_tint, tint); dt_bauhaus_combobox_clear(g->presets); dt_bauhaus_combobox_add(g->presets, _("camera white balance")); dt_bauhaus_combobox_add(g->presets, _("spot white balance")); dt_bauhaus_combobox_add(g->presets, _("passthrough")); g->preset_cnt = 3; const char *wb_name = NULL; char makermodel[1024]; char *model = makermodel; dt_colorspaces_get_makermodel_split(makermodel, 1024, &model, self->dev->image_storage.exif_maker, self->dev->image_storage.exif_model); if(!dt_image_is_ldr(&self->dev->image_storage)) for(int i=0; i<wb_preset_count; i++) { if(g->preset_cnt >= 50) break; if(!strcmp(wb_preset[i].make, makermodel) && !strcmp(wb_preset[i].model, model)) { if(!wb_name || strcmp(wb_name, wb_preset[i].name)) { wb_name = wb_preset[i].name; dt_bauhaus_combobox_add(g->presets, _(wb_preset[i].name)); g->preset_num[g->preset_cnt++] = i; } } } if(fabsf(p->coeffs[0]-fp->coeffs[0]) + fabsf(p->coeffs[1]-fp->coeffs[1]) + fabsf(p->coeffs[2]-fp->coeffs[2]) < 0.01) dt_bauhaus_combobox_set(g->presets, 0); else dt_bauhaus_combobox_set(g->presets, -1); dt_bauhaus_slider_set(g->finetune, 0); gtk_widget_set_sensitive(g->finetune, 0); }
/** Refresh albums */ static void refresh_albums(dt_storage_flickr_gui_data_t *ui) { int i; gtk_widget_set_sensitive(GTK_WIDGET(ui->album_list), FALSE); if(ui->flickr_api == NULL || ui->flickr_api->needsReauthentication == TRUE) { if(ui->flickr_api != NULL) _flickr_api_free(ui->flickr_api); ui->flickr_api = _flickr_api_authenticate(ui); if(ui->flickr_api != NULL) { set_status(ui, _("authenticated"), "#7fe07f"); } else { set_status(ui, _("not authenticated"), "#e07f7f"); gtk_widget_set_sensitive(GTK_WIDGET(ui->album_list), FALSE); return; } } // First clear the cobobox except first 2 items (none / create new album) dt_bauhaus_combobox_clear(ui->album_list); ui->albums = _flickr_api_photosets(ui->flickr_api, gtk_entry_get_text(ui->user_entry)); if(ui->albums) { // Add standard action dt_bauhaus_combobox_add(ui->album_list, _("without album")); dt_bauhaus_combobox_add(ui->album_list, _("create new album")); // dt_bauhaus_combobox_add(ui->album_list, ""); // Separator // FIXME: bauhaus doesn't support separators // Then add albums from list... for(i = 0; ui->albums[i]; i++) { char data[512] = { 0 }; snprintf(data, sizeof(data), "%s (%i)", ui->albums[i]->title, ui->albums[i]->photos_count); dt_bauhaus_combobox_add(ui->album_list, data); } dt_bauhaus_combobox_set(ui->album_list, 2); gtk_widget_hide(GTK_WIDGET(ui->create_box)); // Hide create album box... } else { // Failed to parse feed of album... // Lets notify somehow... dt_bauhaus_combobox_set(ui->album_list, 0); } gtk_widget_set_sensitive(GTK_WIDGET(ui->album_list), TRUE); }
void gui_update(struct dt_iop_module_t *self) { dt_iop_module_t *module = (dt_iop_module_t *)self; self->request_color_pick = DT_REQUEST_COLORPICK_OFF; self->color_picker_box[0] = self->color_picker_box[1] = .25f; self->color_picker_box[2] = self->color_picker_box[3] = .75f; self->color_picker_point[0] = self->color_picker_point[1] = 0.5f; dt_iop_temperature_gui_data_t *g = (dt_iop_temperature_gui_data_t *)self->gui_data; dt_iop_temperature_params_t *p = (dt_iop_temperature_params_t *)module->params; dt_iop_temperature_params_t *fp = (dt_iop_temperature_params_t *)module->default_params; float temp, tint, mul[3]; for(int k = 0; k < 3; k++) mul[k] = g->daylight_wb[k] / p->coeffs[k]; convert_rgb_to_k(mul, &temp, &tint); dt_bauhaus_slider_set(g->scale_r, p->coeffs[0]); dt_bauhaus_slider_set(g->scale_g, p->coeffs[1]); dt_bauhaus_slider_set(g->scale_b, p->coeffs[2]); dt_bauhaus_slider_set(g->scale_k, temp); dt_bauhaus_slider_set(g->scale_tint, tint); dt_bauhaus_combobox_clear(g->presets); dt_bauhaus_combobox_add(g->presets, _("camera white balance")); dt_bauhaus_combobox_add(g->presets, _("spot white balance")); g->preset_cnt = DT_IOP_NUM_OF_STD_TEMP_PRESETS; dt_bauhaus_combobox_set(g->presets, -1); dt_bauhaus_slider_set(g->finetune, 0); gtk_widget_set_sensitive(g->finetune, 0); const char *wb_name = NULL; char makermodel[1024]; char *model = makermodel; dt_colorspaces_get_makermodel_split(makermodel, sizeof(makermodel), &model, self->dev->image_storage.exif_maker, self->dev->image_storage.exif_model); if(!dt_image_is_ldr(&self->dev->image_storage)) for(int i = 0; i < wb_preset_count; i++) { if(g->preset_cnt >= 50) break; if(!strcmp(wb_preset[i].make, makermodel) && !strcmp(wb_preset[i].model, model)) { if(!wb_name || strcmp(wb_name, wb_preset[i].name)) { wb_name = wb_preset[i].name; dt_bauhaus_combobox_add(g->presets, _(wb_preset[i].name)); g->preset_num[g->preset_cnt++] = i; } } } if(memcmp(p->coeffs, fp->coeffs, 3 * sizeof(float)) == 0) dt_bauhaus_combobox_set(g->presets, 0); else { gboolean found = FALSE; // look through all added presets for(int j = DT_IOP_NUM_OF_STD_TEMP_PRESETS; !found && (j < g->preset_cnt); j++) { // look through all variants of this preset, with different tuning for(int i = g->preset_num[j]; !found && !strcmp(wb_preset[i].make, makermodel) && !strcmp(wb_preset[i].model, model) && !strcmp(wb_preset[i].name, wb_preset[g->preset_num[j]].name); i++) { float coeffs[3]; for(int k = 0; k < 3; k++) coeffs[k] = wb_preset[i].channel[k]; if(memcmp(coeffs, p->coeffs, 3 * sizeof(float)) == 0) { // got exact match! dt_bauhaus_combobox_set(g->presets, j); gtk_widget_set_sensitive(g->finetune, 1); dt_bauhaus_slider_set(g->finetune, wb_preset[i].tuning); found = TRUE; break; } } } if(!found) { // ok, we haven't found exact match, maybe this was interpolated? // look through all added presets for(int j = DT_IOP_NUM_OF_STD_TEMP_PRESETS; !found && (j < g->preset_cnt); j++) { // look through all variants of this preset, with different tuning int i = g->preset_num[j] + 1; while(!found && !strcmp(wb_preset[i].make, makermodel) && !strcmp(wb_preset[i].model, model) && !strcmp(wb_preset[i].name, wb_preset[g->preset_num[j]].name)) { // let's find gaps if(wb_preset[i - 1].tuning + 1 == wb_preset[i].tuning) { i++; continue; } // we have a gap! // we do not know what finetuning value was set, we need to bruteforce to find it for(int tune = wb_preset[i - 1].tuning + 1; !found && (tune < wb_preset[i].tuning); tune++) { wb_data interpolated = {.tuning = tune }; dt_wb_preset_interpolate(&wb_preset[i - 1], &wb_preset[i], &interpolated); float coeffs[3]; for(int k = 0; k < 3; k++) coeffs[k] = interpolated.channel[k]; if(memcmp(coeffs, p->coeffs, 3 * sizeof(float)) == 0) { // got exact match! dt_bauhaus_combobox_set(g->presets, j); gtk_widget_set_sensitive(g->finetune, 1); dt_bauhaus_slider_set(g->finetune, tune); found = TRUE; break; } } i++; } } } } }
/** Refresh albums */ static void _piwigo_refresh_albums(dt_storage_piwigo_gui_data_t *ui, const gchar *select_album) { gtk_widget_set_sensitive(GTK_WIDGET(ui->album_list), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(ui->parent_album_list), FALSE); if(ui->api == NULL || ui->api->authenticated == FALSE) { _piwigo_authenticate(ui); if(ui->api == NULL || !ui->api->authenticated) return; } gchar *to_select; int index = 0; // get the new album name, it will be checked in the if(select_album == NULL) { to_select = g_strdup(dt_bauhaus_combobox_get_text(ui->album_list)); if(to_select) { // cut the count of picture in album to get the name only gchar *p = to_select; while(*p) { if(*p == ' ' && *(p+1) == '(') { *p = '\0'; break; } p++; } } } else to_select = g_strdup(select_album); // First clear the combobox except first 2 items (none / create new album) dt_bauhaus_combobox_clear(ui->album_list); dt_bauhaus_combobox_clear(ui->parent_album_list); g_list_free(ui->albums); ui->albums = NULL; GList *args = NULL; args = _piwigo_query_add_arguments(args, "method", "pwg.categories.getList"); args = _piwigo_query_add_arguments(args, "cat_id", "0"); args = _piwigo_query_add_arguments(args, "recursive", "true"); _piwigo_api_post(ui->api, args, NULL, FALSE); g_list_free(args); if(ui->api->response && !ui->api->error_occured) { dt_bauhaus_combobox_add(ui->album_list, _("create new album")); dt_bauhaus_combobox_add(ui->parent_album_list, _("---")); JsonObject *result = json_node_get_object(json_object_get_member(ui->api->response, "result")); JsonArray *albums = json_object_get_array_member(result, "categories"); if(json_array_get_length(albums)>0 && index==0) index = 1; if(index > json_array_get_length(albums) - 1) index = json_array_get_length(albums) - 1; for(int i = 0; i < json_array_get_length(albums); i++) { char data[MAX_ALBUM_NAME_SIZE] = { 0 }; JsonObject *album = json_array_get_object_element(albums, i); _piwigo_album_t *new_album = g_malloc0(sizeof(struct _piwigo_album_t)); g_strlcpy(new_album->name, json_object_get_string_member(album, "name"), sizeof(new_album->name)); new_album->id = json_object_get_int_member(album, "id"); new_album->size = json_object_get_int_member(album, "nb_images"); const int isroot = json_object_get_null_member(album, "id_uppercat"); int indent = 0; if(!isroot) { const char *hierarchy = json_object_get_string_member(album, "uppercats"); char const *p = hierarchy; while(*p++) if(*p == ',') indent++; } snprintf(data, sizeof(data), "%*c%s (%"PRId64")", indent * 3, ' ', new_album->name, new_album->size); if(to_select && !strcmp(new_album->name, to_select)) index = i + 1; g_strlcpy(new_album->label, data, sizeof(new_album->label)); ui->albums = g_list_append(ui->albums, new_album); dt_bauhaus_combobox_add_aligned(ui->album_list, data, DT_BAUHAUS_COMBOBOX_ALIGN_LEFT); dt_bauhaus_combobox_add_aligned(ui->parent_album_list, data, DT_BAUHAUS_COMBOBOX_ALIGN_LEFT); } } else dt_control_log(_("cannot refresh albums")); g_free(to_select); gtk_widget_set_sensitive(GTK_WIDGET(ui->album_list), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(ui->parent_album_list), TRUE); dt_bauhaus_combobox_set(ui->album_list, index); }