Browse Source

Display the output basename only.

Do not display the full pathname on the output button label, but
only the basename.
master
Damien Goutte-Gattat 2 years ago
parent
commit
af82777dba
  1. 16
      src/encrypt.c

16
src/encrypt.c

@ -47,6 +47,7 @@ typedef struct {
const char *original_filename;
char *output_filename;
char *output_basename;
gboolean output_filename_userset;
GtkWidget *ok_button;
@ -64,9 +65,11 @@ set_default_output_filename(yki_encrypt_data_t *yki, const char *original)
yki->original_filename = original;
g_free(yki->output_filename);
g_free(yki->output_basename);
yki->output_filename = g_strdup_printf("%s.%s", yki->original_filename, yki->armored ? "asc" : "gpg");
yki->output_basename = g_path_get_basename(yki->output_filename);
gtk_button_set_label(GTK_BUTTON(yki->output_button), yki->output_filename);
gtk_button_set_label(GTK_BUTTON(yki->output_button), yki->output_basename);
}
@ -138,7 +141,6 @@ output_clicked(GtkButton *button, gpointer data)
{
yki_encrypt_data_t *yki = (yki_encrypt_data_t *)data;
GtkWidget *dlg;
char *filename;
dlg = gtk_file_chooser_dialog_new("Save as",
NULL,
@ -147,18 +149,18 @@ output_clicked(GtkButton *button, gpointer data)
"_OK", GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dlg), yki->output_filename);
filename = g_path_get_basename(yki->output_filename);
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dlg), filename);
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dlg), yki->output_basename);
if ( gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_ACCEPT ) {
g_free(yki->output_filename);
g_free(yki->output_basename);
yki->output_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dlg));
yki->output_filename_userset = TRUE;
gtk_button_set_label(GTK_BUTTON(yki->output_button), yki->output_filename);
yki->output_basename = g_path_get_basename(yki->output_filename);
gtk_button_set_label(GTK_BUTTON(yki->output_button), yki->output_basename);
}
gtk_widget_destroy(dlg);
g_free(filename);
}
static gboolean
@ -341,7 +343,6 @@ yki_encrypt(gpgme_ctx_t gpgme, const char *file, GError **error)
yki_encrypt_data_t yki = { 0 };
gpgutil_file_t in = { 0 }, out = { 0 };
GtkDialog *dlg;
gchar *outname;
int ret;
g_assert(gpgme && file);
@ -371,6 +372,7 @@ yki_encrypt(gpgme_ctx_t gpgme, const char *file, GError **error)
gtk_widget_destroy(GTK_WIDGET(dlg));
g_free(yki.output_filename);
g_free(yki.output_basename);
return ret;
}

Loading…
Cancel
Save