aboutsummaryrefslogtreecommitdiff
path: root/src/dw-hdfsee.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2012-02-04 15:53:25 -0800
committerThomas White <taw@physics.org>2012-02-22 15:27:45 +0100
commit959c5f3d6500f279efde55bd288af83f94b31fac (patch)
tree2b763b33208a0b8732c66c0ca4deb90b8595ac3e /src/dw-hdfsee.c
parent9b97a67ad4602086a0cb2fd393c70e253b13649c (diff)
hdfsee: Set default filename
Diffstat (limited to 'src/dw-hdfsee.c')
-rw-r--r--src/dw-hdfsee.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c
index a2a8751a..3a99bd30 100644
--- a/src/dw-hdfsee.c
+++ b/src/dw-hdfsee.c
@@ -68,6 +68,7 @@ static gint displaywindow_closed(GtkWidget *window, DisplayWindow *dw)
}
if ( dw->image != NULL ) {
+ free(dw->image->filename);
free(dw->image->data);
free(dw->image->flags);
free(dw->image);
@@ -1148,6 +1149,7 @@ static gint displaywindow_save(GtkWidget *widget, DisplayWindow *dw)
{
GtkWidget *d, *hbox, *l, *cb;
struct savedialog *cd;
+ char *fn, *bfn;
d = gtk_file_chooser_dialog_new("Save Image",
GTK_WINDOW(dw->window),
@@ -1156,6 +1158,19 @@ static gint displaywindow_save(GtkWidget *widget, DisplayWindow *dw)
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
+ bfn = safe_basename(dw->image->filename);
+ if ( bfn != NULL ) {
+ fn = malloc(strlen(bfn)+10);
+ if ( fn != NULL ) {
+ sprintf(fn, "%s.png", bfn);
+ STATUS("%s'\n", fn);
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(d),
+ fn);
+ free(fn);
+ }
+ free(bfn);
+ }
+
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(d),
TRUE);
@@ -1793,6 +1808,7 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
if ( !fail ) {
dw->image = calloc(1, sizeof(struct image));
+ dw->image->filename = strdup(filename);
hdf5_read(dw->hdfile, dw->image, 0);
} else {
ERROR("Couldn't select path\n");