aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2018-10-29 22:58:04 +0100
committerThomas White <taw@bitwiz.me.uk>2018-10-29 22:58:04 +0100
commit6171bc9d7f86ea0ac1c6abd4a213850fa4f81300 (patch)
tree7ee1c71cec061389bd7c04d914c2b0e03b101b48
parentb550cf48a14e48245098da4935204dd334319f08 (diff)
Simplify presentation file record
-rw-r--r--src/narrative_window.c7
-rw-r--r--src/presentation.c23
-rw-r--r--src/presentation.h2
3 files changed, 17 insertions, 15 deletions
diff --git a/src/narrative_window.c b/src/narrative_window.c
index 3ff369c..7f3690e 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -196,15 +196,12 @@ static void about_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
static void save_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
{
NarrativeWindow *nw = vp;
- GFile *file;
- if ( nw->p->uri == NULL ) {
+ if ( nw->p->file == NULL ) {
return saveas_sig(NULL, NULL, nw);
}
- file = g_file_new_for_uri(nw->p->uri);
- save_presentation(nw->p, file, nw->p->stylesheet_from);
- g_object_unref(file);
+ save_presentation(nw->p, nw->p->file, nw->p->stylesheet_from);
}
diff --git a/src/presentation.c b/src/presentation.c
index 810293d..e1df7c8 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -44,7 +44,8 @@ void free_presentation(struct presentation *p)
int final = 0;
/* FIXME: Loads of stuff leaks here */
- free(p->uri);
+ g_object_unref(p->file);
+ g_object_unref(p->stylesheet_from);
imagestore_destroy(p->is);
free(p);
@@ -56,12 +57,10 @@ void free_presentation(struct presentation *p)
char *get_titlebar_string(struct presentation *p)
{
- if ( p == NULL || p->uri == NULL ) {
+ if ( p == NULL || p->file == NULL ) {
return strdup(_("(untitled)"));
} else {
- GFile *f = g_file_new_for_uri(p->uri);
- char *bn = g_file_get_basename(f);
- g_object_unref(f);
+ char *bn = g_file_get_basename(p->file);
return bn;
}
}
@@ -129,7 +128,8 @@ struct presentation *new_presentation(const char *imagestore)
new = calloc(1, sizeof(struct presentation));
if ( new == NULL ) return NULL;
- new->uri = NULL;
+ new->file = NULL;
+ new->stylesheet_from = NULL;
new->scblocks = NULL;
@@ -169,6 +169,9 @@ int save_presentation(struct presentation *p, GFile *file, GFile *ssfile)
g_object_unref(fh);
if ( ssfile != NULL ) {
+ char *uri = g_file_get_uri(ssfile);
+ printf(_("Saving stylesheet to %s\n"), uri);
+ g_free(uri);
sr = stylesheet_save(p->stylesheet, ssfile);
if ( sr ) {
fprintf(stderr, _("Couldn't save stylesheet\n"));
@@ -181,7 +184,7 @@ int save_presentation(struct presentation *p, GFile *file, GFile *ssfile)
if ( r || sr ) return 1;
imagestore_set_parent(p->is, g_file_get_parent(file));
- p->uri = g_file_get_uri(file);
+ p->file = file;
p->saved = 1;
update_titlebar(p->narrative_window);
return 0;
@@ -343,8 +346,10 @@ int load_presentation(struct presentation *p, GFile *file)
set_slide_size_from_stylesheet(p);
- assert(p->uri == NULL);
- p->uri = g_file_get_uri(file);
+ assert(p->file == NULL);
+ p->file = file;
+ g_object_ref(file);
+
imagestore_set_parent(p->is, g_file_get_parent(file));
return 0;
diff --git a/src/presentation.h b/src/presentation.h
index 57542ca..a3e10cc 100644
--- a/src/presentation.h
+++ b/src/presentation.h
@@ -40,7 +40,7 @@ struct menu_pl;
struct presentation
{
- char *uri;
+ GFile *file;
GFile *stylesheet_from;
int completely_empty;
int saved;