aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-11-06 23:31:43 +0100
committerThomas White <taw@bitwiz.org.uk>2011-11-06 23:31:43 +0100
commit4910224d9f6273e6c78458353f6bbfec836ea35d (patch)
tree0f0c24b95f45767493852576d10402fc26f4fd15 /src
parente4cd5c54a16bf68eb57f6acce50e13bcfd3797ab (diff)
Update the title bar on load/save
Diffstat (limited to 'src')
-rw-r--r--src/loadsave.c9
-rw-r--r--src/mainwindow.c24
-rw-r--r--src/mainwindow.h1
-rw-r--r--src/presentation.c4
-rw-r--r--src/presentation.h2
5 files changed, 33 insertions, 7 deletions
diff --git a/src/loadsave.c b/src/loadsave.c
index 8b7d9e1..e6a03ff 100644
--- a/src/loadsave.c
+++ b/src/loadsave.c
@@ -35,6 +35,7 @@
#include "objects.h"
#include "stylesheet.h"
#include "slide_render.h"
+#include "mainwindow.h"
static int alloc_children(struct ds_node *node)
@@ -666,6 +667,10 @@ int load_presentation(struct presentation *p, const char *filename)
return r; /* Error */
}
+ assert(p->filename == NULL);
+ p->filename = strdup(filename);
+ update_titlebar(p);
+
p->cur_edit_slide = p->slides[0];
return 0;
@@ -797,6 +802,10 @@ int save_presentation(struct presentation *p, const char *filename)
}
serialize_end(&ser);
+ if ( p->filename != NULL ) free(p->filename);
+ p->filename = strdup(filename);
+ update_titlebar(p);
+
fclose(fh);
return 0;
}
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 1101345..fce5306 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -1074,11 +1074,28 @@ static void dnd_leave(GtkWidget *widget, GdkDragContext *drag_context,
}
+void update_titlebar(struct presentation *p)
+{
+ get_titlebar_string(p);
+
+ if ( p->window != NULL ) {
+
+ char *title;
+
+ title = malloc(strlen(p->titlebar)+14);
+ sprintf(title, "%s - Colloquium", p->titlebar);
+ gtk_window_set_title(GTK_WINDOW(p->window), title);
+ printf("Set title '%s'\n", title);
+ free(title);
+
+ }
+}
+
+
int open_mainwindow(struct presentation *p)
{
GtkWidget *window;
GtkWidget *vbox;
- char *title;
GtkWidget *sw;
GtkTargetEntry targets[1];
@@ -1090,10 +1107,7 @@ int open_mainwindow(struct presentation *p)
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
p->window = window;
- title = malloc(strlen(p->titlebar)+14);
- sprintf(title, "%s - Colloquium", p->titlebar);
- gtk_window_set_title(GTK_WINDOW(window), title);
- free(title);
+ update_titlebar(p);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(close_sig), p);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 816b17c..feac092 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -30,6 +30,7 @@
extern int open_mainwindow(struct presentation *p);
extern void notify_slide_changed(struct presentation *p);
+extern void update_titlebar(struct presentation *p);
extern void redraw_overlay(struct presentation *p);
diff --git a/src/presentation.c b/src/presentation.c
index 75b76d0..f954503 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -215,7 +215,7 @@ static char *safe_basename(const char *in)
}
-static void update_titlebar(struct presentation *p)
+void get_titlebar_string(struct presentation *p)
{
free(p->titlebar);
@@ -249,7 +249,7 @@ struct presentation *new_presentation()
new->filename = NULL;
new->titlebar = NULL;
- update_titlebar(new);
+ get_titlebar_string(new);
new->window = NULL;
new->ui = NULL;
diff --git a/src/presentation.h b/src/presentation.h
index 854f824..9b03af1 100644
--- a/src/presentation.h
+++ b/src/presentation.h
@@ -187,6 +187,8 @@ extern struct slide *add_slide(struct presentation *p, int pos);
extern int insert_slide(struct presentation *p, struct slide *s, int pos);
extern void free_slide(struct slide *s);
+extern void get_titlebar_string(struct presentation *p);
+
extern int add_object_to_slide(struct slide *s, struct object *o);
extern void remove_object_from_slide(struct slide *s, struct object *o);
extern struct object *find_object_at_position(struct slide *s,