Beispiel #1
0
/** Refresh albums */
void static refresh_albums(dt_storage_flickr_gui_data_t *ui)
{
  int i;
  gtk_widget_set_sensitive( GTK_WIDGET(ui->comboBox1), 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->comboBox1 ) ,FALSE);
      return;
    }
  }

  // First clear the model of data except first item (Create new album)
  GtkTreeModel *model=gtk_combo_box_get_model(GTK_COMBO_BOX(ui->comboBox1));
  gtk_list_store_clear (GTK_LIST_STORE(model));

  ui->albums = _flickr_api_photosets(ui->flickr_api, gtk_entry_get_text(ui->entry1));
  if( ui->albums )
  {

    // Add standard action
    gtk_combo_box_text_append_text(ui->comboBox1, _("without album") );
    gtk_combo_box_text_append_text(ui->comboBox1, _("create new album") );
    gtk_combo_box_text_append_text(ui->comboBox1, "" );// Separator

    // Then add albums from list...
    for(i=0; ui->albums[i]; i++)
    {
      char data[512]= {0};
      sprintf(data,"%s (%i)", ui->albums[i]->title, ui->albums[i]->photos_count);
      gtk_combo_box_text_append_text(ui->comboBox1, g_strdup(data));
    }
    gtk_combo_box_set_active(GTK_COMBO_BOX(ui->comboBox1), 3);
    gtk_widget_hide( GTK_WIDGET(ui->hbox1) ); // Hide create album box...
  }
  else
  {
    // Failed to parse feed of album...
    // Lets notify somehow...
    gtk_combo_box_set_active(GTK_COMBO_BOX(ui->comboBox1), 0);
  }
  gtk_widget_set_sensitive( GTK_WIDGET(ui->comboBox1), TRUE);

}
Beispiel #2
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);
}
Beispiel #3
0
void*
get_params(dt_imageio_module_storage_t *self)
{
  // have to return the size of the struct to store (i.e. without all the variable pointers at the end)
  // TODO: if a hash to encrypted data is stored here, return only this size and store it at the beginning of the struct!
  dt_storage_flickr_gui_data_t *ui =(dt_storage_flickr_gui_data_t *)self->gui_data;
  dt_storage_flickr_params_t *d = (dt_storage_flickr_params_t *)g_malloc(sizeof(dt_storage_flickr_params_t));
  if(!d) return NULL;
  memset(d,0,sizeof(dt_storage_flickr_params_t));
  d->hash = 1;

  // fill d from controls in ui
  if( ui->flickr_api && ui->flickr_api->needsReauthentication == FALSE)
  {
    // We are authenticated and off to actually export images..
    d->flickr_api = ui->flickr_api;
    int index = gtk_combo_box_get_active(GTK_COMBO_BOX(ui->comboBox1));
    if( index >= 0 )
    {
      switch(index)
      {
        case 0: // No album
          d->flickr_api->current_album = NULL;
          break;
        case 1: // Create new album
          d->flickr_api->current_album = NULL;
          d->flickr_api->album_title = g_strdup( gtk_entry_get_text( ui->entry3 ) );
          d->flickr_api->album_summary = g_strdup( gtk_entry_get_text( ui->entry4) );
          d->flickr_api->new_album = TRUE;
          break;
        default:
          // use existing album
          d->flickr_api->current_album = flickcurl_photosets_getInfo(d->flickr_api->fc,ui->albums[index-3]->id);
          if( d->flickr_api->current_album == NULL )
          {
            // Something went wrong...
            fprintf(stderr,"Something went wrong.. album index %d = NULL\n",index-3 );
            g_free(d);
            return NULL;
          }
          break;
      }

    }
    else
    {
      g_free(d);
      return NULL;
    }

    d->export_tags = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ui->checkButton2));

    /* Handle the permissions */
    int perm_index = (int) gtk_combo_box_get_active(GTK_COMBO_BOX(ui->permsComboBox));
    switch(perm_index)
    {
      case 0: // Private
        d->public_perm = 0;
        d->friend_perm = 0;
        d->family_perm = 0;
        break;
      case 1: // Friends
        d->public_perm = 0;
        d->friend_perm = 1;
        d->family_perm = 0;
        break;
      case 2: // Family
        d->public_perm = 0;
        d->friend_perm = 0;
        d->family_perm = 1;
        break;
      case 3: // Friend + Family
        d->public_perm = 0;
        d->friend_perm = 1;
        d->family_perm = 1;
        break;
      case 4: //Public
        d->public_perm = 1;
        d->friend_perm = 0;
        d->family_perm = 0;
        break;
    }

    // Let UI forget about this api context and recreate a new one for further usage...
    ui->flickr_api = _flickr_api_authenticate(ui);
    if (ui->flickr_api)
    {
      set_status(ui,_("authenticated"), "#7fe07f");
    }
    else
    {
      set_status(ui,_("not authenticated"), "#e07f7f");
      gtk_widget_set_sensitive(GTK_WIDGET( ui->comboBox1 ) ,FALSE);
    }
  }
  else
  {
    set_status(ui,_("not authenticated"), "#e07f7f");
    gtk_widget_set_sensitive(GTK_WIDGET( ui->comboBox1 ) ,FALSE);
    g_free(d);
    return NULL;
  }
  return d;
}