aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--data/colloquium.ui1
-rw-r--r--src/mainwindow.c14
-rw-r--r--src/notes.c126
-rw-r--r--src/notes.h37
-rw-r--r--src/presentation.c4
-rw-r--r--src/presentation.h5
-rw-r--r--src/slideshow.c3
8 files changed, 192 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 868caed..0b98611 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,13 +11,13 @@ LDADD = $(top_builddir)/lib/libgnu.a @IGNORE_UNUSED_LIBRARIES_CFLAGS@
src_colloquium_SOURCES = src/colloquium.c src/presentation.c src/mainwindow.c \
src/slide_render.c src/objects.c src/slideshow.c \
src/stylesheet.c src/loadsave.c src/tool_text.c \
- src/tool_select.c src/tool_image.c
+ src/tool_select.c src/tool_image.c src/notes.c
INCLUDES = "-I$(top_srcdir)/data"
EXTRA_DIST += src/presentation.h src/mainwindow.h src/slide_render .h \
src/objects.h src/slideshow.h src/stylesheet.h src/loadsave.h \
- src/tool_text.h src/tool_select.h
+ src/tool_text.h src/tool_select.h src/tool_image.h src/notes.h
colloquiumdir = $(datadir)/colloquium
colloquium_DATA = data/colloquium.ui
diff --git a/data/colloquium.ui b/data/colloquium.ui
index 1033b48..131f380 100644
--- a/data/colloquium.ui
+++ b/data/colloquium.ui
@@ -32,6 +32,7 @@
<menu name="tools" action="ToolsAction">
<menuitem name="slideshow" action="TSlideshowAction" />
+ <menuitem name="notes" action="NotesAction" />
<menuitem name="preferences" action="PrefsAction" />
</menu>
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 6afd548..26fcfaf 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -42,6 +42,7 @@
#include "tool_select.h"
#include "tool_text.h"
#include "tool_image.h"
+#include "notes.h"
static void add_ui_sig(GtkUIManager *ui, GtkWidget *widget,
@@ -393,6 +394,10 @@ void notify_slide_changed(struct presentation *p, struct slide *np)
update_toolbar(p);
redraw_slide(p->cur_edit_slide);
+ if ( p->notes != NULL ) {
+ notify_notes_slide_changed(p, np);
+ }
+
if ( (p->slideshow != NULL) && p->slideshow_linked ) {
notify_slideshow_slide_changed(p, np);
}
@@ -464,6 +469,13 @@ static gint open_stylesheet_sig(GtkWidget *widget, struct presentation *p)
}
+static gint open_notes_sig(GtkWidget *widget, struct presentation *p)
+{
+ open_notes(p);
+ return FALSE;
+}
+
+
enum tool_id
{
TOOL_SELECT,
@@ -579,6 +591,8 @@ static void add_menu_bar(struct presentation *p, GtkWidget *vbox)
{ "ToolsAction", NULL, "_Tools", NULL, NULL, NULL },
{ "TSlideshowAction", GTK_STOCK_FULLSCREEN, "_Start slideshow",
"F5", NULL, G_CALLBACK(start_slideshow_sig) },
+ { "NotesAction", NULL, "_Open slide notes",
+ "F5", NULL, G_CALLBACK(open_notes_sig) },
{ "PrefsAction", GTK_STOCK_PREFERENCES, "_Preferences",
NULL, NULL, NULL },
diff --git a/src/notes.c b/src/notes.c
new file mode 100644
index 0000000..026612b
--- /dev/null
+++ b/src/notes.c
@@ -0,0 +1,126 @@
+/*
+ * notes.c
+ *
+ * Colloquium - A tiny presentation program
+ *
+ * Copyright (c) 2011 Thomas White <taw@bitwiz.org.uk>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <gtk/gtk.h>
+
+#include "presentation.h"
+
+
+struct notes
+{
+ GtkWidget *window;
+ GtkWidget *v;
+};
+
+
+static void set_notes_title(struct presentation *p)
+{
+ gtk_window_set_title(GTK_WINDOW(p->notes->window), "Colloquium notes");
+}
+
+
+static void update_notes(struct presentation *p)
+{
+ GtkTextBuffer *tb;
+
+ if ( p->notes == NULL ) return;
+
+ tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(p->notes->v));
+ gtk_text_buffer_set_text(tb, p->cur_edit_slide->notes, -1);
+}
+
+
+static void grab_notes(struct notes *n, struct slide *s)
+{
+ gchar *text;
+ GtkTextBuffer *tb;
+ GtkTextIter i1, i2;
+
+ if ( n == NULL ) return;
+
+ tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(n->v));
+ gtk_text_buffer_get_start_iter(tb, &i1);
+ gtk_text_buffer_get_end_iter(tb, &i2);
+ text = gtk_text_buffer_get_text(tb, &i1, &i2, TRUE);
+
+ free(s->notes);
+ s->notes = text;
+}
+
+
+void notify_notes_slide_changed(struct presentation *p, struct slide *np)
+{
+ grab_notes(p->notes, p->cur_notes_slide);
+ p->cur_notes_slide = np;
+ update_notes(p);
+}
+
+
+static gint close_notes_sig(GtkWidget *w, struct presentation *p)
+{
+ grab_notes(p->notes, p->cur_notes_slide);
+ return FALSE;
+}
+
+
+void open_notes(struct presentation *p)
+{
+ struct notes *n;
+ GtkWidget *sc;
+ PangoFontDescription *desc;
+
+ if ( p->notes != NULL ) return; /* Already open */
+
+ n = malloc(sizeof(struct notes));
+ if ( n == NULL ) return;
+ p->notes = n;
+
+ p->cur_notes_slide = p->cur_edit_slide;
+
+ n->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ sc = gtk_scrolled_window_new(NULL, NULL);
+ gtk_container_add(GTK_CONTAINER(n->window), sc);
+
+ n->v = gtk_text_view_new();
+ desc = pango_font_description_from_string("Sans 24");
+ gtk_widget_modify_font(n->v, desc);
+ pango_font_description_free(desc);
+ gtk_text_view_set_left_margin(GTK_TEXT_VIEW(n->v), 30);
+ gtk_text_view_set_right_margin(GTK_TEXT_VIEW(n->v), 30);
+ gtk_container_add(GTK_CONTAINER(sc), n->v);
+
+ g_signal_connect(G_OBJECT(n->v), "destroy",
+ G_CALLBACK(close_notes_sig), p);
+
+ set_notes_title(p);
+ gtk_widget_show_all(n->window);
+
+ update_notes(p);
+}
diff --git a/src/notes.h b/src/notes.h
new file mode 100644
index 0000000..b739acb
--- /dev/null
+++ b/src/notes.h
@@ -0,0 +1,37 @@
+/*
+ * notes.h
+ *
+ * Colloquium - A tiny presentation program
+ *
+ * Copyright (c) 2011 Thomas White <taw@bitwiz.org.uk>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NOTES_H
+#define NOTES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+struct notes;
+
+extern void open_notes(struct presentation *p);
+
+extern void notify_notes_slide_changed(struct presentation *p,
+ struct slide *np);
+
+#endif /* NOTES_H */
diff --git a/src/presentation.c b/src/presentation.c
index 4aedc71..6ae3943 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -125,6 +125,8 @@ struct slide *new_slide()
new->rendered_proj = NULL;
new->rendered_thumb = NULL;
+ new->notes = strdup("");
+
return new;
}
@@ -325,11 +327,13 @@ struct presentation *new_presentation()
/* FIXME: Should be just one of these */
new->prefs = calloc(1, sizeof(struct prefs));
new->prefs->b_splits = 1;
+ new->prefs->open_notes = 1;
new->window = NULL;
new->ui = NULL;
new->action_group = NULL;
new->slideshow = NULL;
+ new->notes = NULL;
new->slide_width = 1024.0;
new->slide_height = 768.0;
diff --git a/src/presentation.h b/src/presentation.h
index 3a781d9..78a73b2 100644
--- a/src/presentation.h
+++ b/src/presentation.h
@@ -46,6 +46,8 @@ struct slide
int num_objects;
struct object **objects;
+
+ char *notes;
};
@@ -106,6 +108,7 @@ struct toolinfo
struct prefs
{
int b_splits;
+ int open_notes;
};
@@ -129,10 +132,12 @@ struct presentation
GtkIMContext *im_context;
GtkWidget *tbox;
GtkWidget *cur_tbox;
+ struct notes *notes;
/* Pointers to the current "editing" and "projection" slides */
struct slide *cur_edit_slide;
struct slide *cur_proj_slide;
+ struct slide *cur_notes_slide;
int slideshow_linked;
/* This is the "native" size of the slide. It only exists to give
diff --git a/src/slideshow.c b/src/slideshow.c
index 02c6bc0..601c79e 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -34,6 +34,7 @@
#include "presentation.h"
#include "slide_render.h"
#include "mainwindow.h"
+#include "notes.h"
static gint ss_destroy_sig(GtkWidget *widget, struct presentation *p)
@@ -274,6 +275,8 @@ void try_start_slideshow(struct presentation *p)
gtk_window_fullscreen(GTK_WINDOW(n));
gtk_widget_show_all(GTK_WIDGET(n));
+ if ( p->prefs->open_notes ) open_notes(p);
+
p->cur_proj_slide = p->cur_edit_slide;
redraw_slide(p->cur_proj_slide);
}