aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-03-27 17:57:31 +0100
committerThomas White <taw@bitwiz.me.uk>2019-03-27 17:57:31 +0100
commit47764e46296e8c6921bbc00b95c05ff153699dc2 (patch)
treeb8f0f1b9b13309207a973d94e851103c4abb2877
parent86f73eac9bd24cde5be223b9973296d479a8deb7 (diff)
Show modified status in narrative title bar
-rw-r--r--libstorycode/presentation.c14
-rw-r--r--libstorycode/presentation.h2
-rw-r--r--src/narrative_window.c64
3 files changed, 47 insertions, 33 deletions
diff --git a/libstorycode/presentation.c b/libstorycode/presentation.c
index d862ac0..817a55a 100644
--- a/libstorycode/presentation.c
+++ b/libstorycode/presentation.c
@@ -50,6 +50,7 @@ struct _presentation
int n_slides;
Slide **slides;
int max_slides;
+ int saved;
const char *language;
};
@@ -65,6 +66,7 @@ Presentation *presentation_new()
p->n_slides = 0;
p->max_slides = 0;
p->imagestore = NULL;
+ p->saved = 1;
#ifdef HAVE_PANGO
p->language = pango_language_to_string(pango_language_get_default());
#else
@@ -102,6 +104,18 @@ int presentation_save(Presentation *p, GFile *file)
}
+void presentation_set_unsaved(Presentation *p)
+{
+ p->saved = 0;
+}
+
+
+int presentation_get_unsaved(Presentation *p)
+{
+ return !p->saved;
+}
+
+
void presentation_free(Presentation *p)
{
/* FIXME: Free narrative, slides, imagestore */
diff --git a/libstorycode/presentation.h b/libstorycode/presentation.h
index ad01382..444024b 100644
--- a/libstorycode/presentation.h
+++ b/libstorycode/presentation.h
@@ -39,6 +39,8 @@ extern Presentation *presentation_new(void);
extern Presentation *presentation_load(GFile *file);
extern int presentation_save(Presentation *p, GFile *file);
extern void presentation_free(Presentation *p);
+extern void presentation_set_unsaved(Presentation *p);
+extern int presentation_get_unsaved(Presentation *p);
extern void presentation_add_stylesheet(Presentation *p, Stylesheet *ss);
extern void presentation_add_narrative(Presentation *p, Narrative *n);
diff --git a/src/narrative_window.c b/src/narrative_window.c
index d80d9cf..c51d3a3 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -81,6 +81,32 @@ static void show_error(NarrativeWindow *nw, const char *err)
}
+static void update_titlebar(NarrativeWindow *nw)
+{
+ char *title;
+ char *title_new;
+
+ title = strdup("test"); // FIXME get_titlebar_string(nw->p);
+ title_new = realloc(title, strlen(title)+16);
+ if ( title_new == NULL ) {
+ free(title);
+ return;
+ } else {
+ title = title_new;
+ }
+
+ strcat(title, " - Colloquium");
+ if ( presentation_get_unsaved(nw->p) ) {
+ strcat(title, " *");
+ }
+ gtk_window_set_title(GTK_WINDOW(nw->window), title);
+
+ /* FIXME: Update all slide windows belonging to this NW */
+
+ free(title);
+}
+
+
static void update_toolbar(NarrativeWindow *nw)
{
// int cur_para;
@@ -282,12 +308,10 @@ static void load_ss_sig(GSimpleAction *action, GVariant *parameter,
static void add_slide_sig(GSimpleAction *action, GVariant *parameter,
gpointer vp)
{
- //NarrativeWindow *nw = vp;
-
- /* FIXME: implementation */
+ NarrativeWindow *nw = vp;
- //nw->p->saved = 0;
- //update_titlebar(nw);
+ presentation_set_unsaved(nw->p);
+ update_titlebar(nw);
}
@@ -441,8 +465,8 @@ static gboolean nw_button_press_sig(GtkWidget *da, GdkEventButton *event,
static void changed_sig(GtkWidget *da, NarrativeWindow *nw)
{
- //nw->p->saved = 0;
- //update_titlebar(nw);
+ presentation_set_unsaved(nw->p);
+ update_titlebar(nw);
}
@@ -631,32 +655,6 @@ GActionEntry nw_entries[] = {
};
-void update_titlebar(NarrativeWindow *nw)
-{
- char *title;
- char *title_new;
-
- title = strdup("test"); // FIXME get_titlebar_string(nw->p);
- title_new = realloc(title, strlen(title)+16);
- if ( title_new == NULL ) {
- free(title);
- return;
- } else {
- title = title_new;
- }
-
- strcat(title, " - Colloquium");
-//FIXME if ( !nw->p->saved ) {
-// strcat(title, " *");
-// }
- gtk_window_set_title(GTK_WINDOW(nw->window), title);
-
- /* FIXME: Update all slide windows belonging to this NW */
-
- free(title);
-}
-
-
//void narrative_window_sw_closed(NarrativeWindow *nw, SlideWindow *sw)
//{
// int i;