/** * @see https://developers.google.com/photos/library/guides/create-albums * @return the id of the newly reacted */ static const gchar *gphoto_create_album(dt_storage_gphoto_gui_data_t *ui, dt_gphoto_context_t *ctx, gchar *name) { struct curl_slist *headers = NULL; gchar *jbody = dt_util_dstrcat(NULL, "{ \"album\": { \"title\": \"%s\"} }", name); headers = curl_slist_append(headers, "Content-type: application/json"); JsonObject *response = gphoto_query_post(ctx, GOOGLE_GPHOTO "v1/albums", headers, NULL, jbody, strlen(jbody)); // add new album into the list dt_gphoto_album_t *album = _json_new_album(response); GtkListStore *model_album = GTK_LIST_STORE(gtk_combo_box_get_model(ui->combo_album)); if(album) { ui_refresh_albums_fill(album, model_album); gtk_combo_box_set_active(ui->combo_album, ui->albums_count); ui->albums_count++; ui_reset_albums_creation(ui); } g_free(jbody); return album?album->id:NULL; }
static gboolean _finalize_store(gpointer user_data) { dt_storage_gphoto_gui_data_t *ui = (dt_storage_gphoto_gui_data_t *)user_data; ui_reset_albums_creation(ui); return FALSE; }
void finalize_store(struct dt_imageio_module_storage_t *self, dt_imageio_module_data_t *data) { gdk_threads_enter(); dt_storage_facebook_gui_data_t *ui = (dt_storage_facebook_gui_data_t*)self->gui_data; ui_reset_albums_creation(ui); ui_refresh_albums(ui); gdk_threads_leave(); }
static void ui_combo_username_changed(GtkComboBox *combo, struct dt_storage_facebook_gui_data_t *ui) { GtkTreeIter iter; gchar *token = NULL; if(!gtk_combo_box_get_active_iter(combo, &iter)) return; // ie: list is empty while clearing the combo GtkTreeModel *model = gtk_combo_box_get_model(combo); gtk_tree_model_get(model, &iter, 1, &token, -1); // get the selected token ui->connected = FALSE; gtk_button_set_label(ui->button_login, _("login")); g_free(ui->facebook_api->token); ui->facebook_api->token = NULL; ui_reset_albums_creation(ui); }