~ubuntu-branches/ubuntu/oneiric/seahorse/oneiric-proposed-201111150713

« back to all changes in this revision

Viewing changes to pgp/seahorse-gpgme-generate.c

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach
  • Date: 2011-04-14 23:26:01 UTC
  • mto: (3.1.7 sid) (1.2.59 upstream)
  • mto: This revision was merged to the branch mainline in revision 97.
  • Revision ID: james.westby@ubuntu.com-20110414232601-a1f1ibqayicoj8sd
ImportĀ upstreamĀ versionĀ 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
    guint type;
110
110
    guint min;
111
111
    guint max;
 
112
    guint def;
112
113
} AlgorithmDesc;
113
114
 
114
115
static AlgorithmDesc available_algorithms[] = {
115
 
    { N_("RSA"),             RSA_RSA,     RSA_MIN,     LENGTH_MAX  },
116
 
    { N_("DSA Elgamal"),     DSA_ELGAMAL, ELGAMAL_MIN, LENGTH_MAX  },
117
 
    { N_("DSA (sign only)"), DSA,         DSA_MIN,     DSA_MAX     },
118
 
    { N_("RSA (sign only)"), RSA_SIGN,    RSA_MIN,     LENGTH_MAX  }
 
116
    { N_("RSA"),             RSA_RSA,     RSA_MIN,     LENGTH_MAX, LENGTH_DEFAULT  },
 
117
    { N_("DSA Elgamal"),     DSA_ELGAMAL, ELGAMAL_MIN, LENGTH_MAX, LENGTH_DEFAULT  },
 
118
    { N_("DSA (sign only)"), DSA,         DSA_MIN,     DSA_MAX,    LENGTH_DEFAULT  },
 
119
    { N_("RSA (sign only)"), RSA_SIGN,    RSA_MIN,     LENGTH_MAX, LENGTH_DEFAULT  }
119
120
};
120
121
 
121
122
/**
276
277
    widget = seahorse_widget_get_widget (swidget, "bits-entry");
277
278
    g_return_if_fail (widget != NULL);
278
279
    bits = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
279
 
    if (bits < 512 || bits > 8192) {
280
 
        g_message ("invalid key size: %s defaulting to 2048", available_algorithms[sel].desc);
281
 
        bits = 2048;
 
280
    if (bits < available_algorithms[sel].min || bits > available_algorithms[sel].max) {
 
281
        bits = available_algorithms[sel].def;
 
282
        g_message ("invalid key size: %s defaulting to %u", available_algorithms[sel].desc, bits);
282
283
    }
283
284
    
284
285
    /* The expiry */
362
363
on_gpgme_generate_algorithm_changed (GtkComboBox *combo, SeahorseWidget *swidget)
363
364
{
364
365
    GtkWidget *widget;
365
 
    gint idx;
 
366
    gint sel;
366
367
    
367
 
    idx = gtk_combo_box_get_active (combo);
368
 
    g_assert (idx < (int)G_N_ELEMENTS (available_algorithms));
 
368
    sel = gtk_combo_box_get_active (combo);
 
369
    g_assert (sel < (int)G_N_ELEMENTS (available_algorithms));
369
370
    
370
371
    widget = seahorse_widget_get_widget (swidget, "bits-entry");
371
372
    g_return_if_fail (widget != NULL);
372
373
    
373
374
    gtk_spin_button_set_range (GTK_SPIN_BUTTON (widget), 
374
 
                               available_algorithms[idx].min, 
375
 
                               available_algorithms[idx].max);
 
375
                               available_algorithms[sel].min,
 
376
                               available_algorithms[sel].max);
376
377
 
377
378
    /* Set sane default key length */
378
 
    if (2048 > available_algorithms[idx].max)
379
 
        gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), available_algorithms[idx].max);
 
379
    if (available_algorithms[sel].def > available_algorithms[sel].max)
 
380
        gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), available_algorithms[sel].max);
380
381
    else
381
 
        gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), 2048);
 
382
        gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), available_algorithms[sel].def);
382
383
}
383
384
 
384
385
/**
435
436
    /* The algoritms */
436
437
    widget = seahorse_widget_get_widget (swidget, "algorithm-choice");
437
438
    g_return_if_fail (widget != NULL);
 
439
#if GTK_CHECK_VERSION (2,91,2)
 
440
    gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT (widget), 0);
 
441
    for(i = 0; i < G_N_ELEMENTS(available_algorithms); i++)
 
442
        gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _(available_algorithms[i].desc));
 
443
#else
438
444
    gtk_combo_box_remove_text (GTK_COMBO_BOX (widget), 0);
439
445
    for(i = 0; i < G_N_ELEMENTS(available_algorithms); i++)
440
446
        gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _(available_algorithms[i].desc));
 
447
#endif
441
448
    gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
442
449
    on_gpgme_generate_algorithm_changed (GTK_COMBO_BOX (widget), swidget);
443
450