aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2014-12-01 22:31:55 +0100
committerThomas White <taw@bitwiz.org.uk>2014-12-01 22:31:55 +0100
commit394367b5ad4ac81fbefa53b241c49f438fc54b4e (patch)
tree22831063bdc6c53ba8b2dc6280a9e0ef87a838af /src
parent356cd2e7e0ceace7dadac7feb578d781543a29f6 (diff)
Hook Save back up
Diffstat (limited to 'src')
-rw-r--r--src/colloquium.c102
-rw-r--r--src/narrative_window.c167
2 files changed, 207 insertions, 62 deletions
diff --git a/src/colloquium.c b/src/colloquium.c
index e3ee61f..588aea8 100644
--- a/src/colloquium.c
+++ b/src/colloquium.c
@@ -102,7 +102,6 @@ GActionEntry app_entries[] = {
{ "new", new_sig, NULL, NULL, NULL },
{ "about", about_sig, NULL, NULL, NULL },
{ "quit", quit_sig, NULL, NULL, NULL },
-
};
@@ -148,14 +147,21 @@ static void colloquium_startup(GApplication *app)
" <attribute name='action'>app.new</attribute>"
" <attribute name='accel'>&lt;Primary&gt;n</attribute>"
" </item>"
+ " <item>"
+ " <attribute name='label'>_Open</attribute>"
+ " <attribute name='action'>app.open</attribute>"
+ " <attribute name='accel'>&lt;Primary&gt;o</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label'>Preferences...</attribute>"
+ " <attribute name='action'>app.prefs</attribute>"
+ " </item>"
" </section>"
" <section>"
" <item>"
" <attribute name='label'>_About</attribute>"
" <attribute name='action'>app.about</attribute>"
" </item>"
- " </section>"
- " <section>"
" <item>"
" <attribute name='label'>_Quit</attribute>"
" <attribute name='action'>app.quit</attribute>"
@@ -170,12 +176,98 @@ static void colloquium_startup(GApplication *app)
" <section>"
" <item>"
" <attribute name='label'>_Save</attribute>"
- " <attribute name='action'>file.save</attribute>"
+ " <attribute name='action'>win.save</attribute>"
" <attribute name='accel'>&lt;Primary&gt;s</attribute>"
" </item>"
" <item>"
+ " <attribute name='label'>Save As...</attribute>"
+ " <attribute name='action'>win.saveas</attribute>"
+ " </item>"
+ " </section>"
+ " <section>"
+ " <item>"
+ " <attribute name='label'>Load stylesheet</attribute>"
+ " <attribute name='action'>win.loadstyle</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label'>Save stylesheet</attribute>"
+ " <attribute name='action'>win.savestyle</attribute>"
+ " </item>"
+ " <item>"
" <attribute name='label'>Export PDF</attribute>"
- " <attribute name='action'>file.exportpdf</attribute>"
+ " <attribute name='action'>win.exportpdf</attribute>"
+ " </item>"
+ " </section>"
+ " </submenu>"
+
+ " <submenu>"
+ " <attribute name='label' translatable='yes'>Edit</attribute>"
+ " <section>"
+ " <item>"
+ " <attribute name='label'>Undo</attribute>"
+ " <attribute name='action'>win.undo</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label'>Redo</attribute>"
+ " <attribute name='action'>win.redo</attribute>"
+ " </item>"
+ " </section>"
+ " <section>"
+ " <item>"
+ " <attribute name='label'>Cut</attribute>"
+ " <attribute name='action'>win.cut</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label'>Copy</attribute>"
+ " <attribute name='action'>win.copy</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label'>Paste</attribute>"
+ " <attribute name='action'>win.paste</attribute>"
+ " </item>"
+ " </section>"
+ " <section>"
+ " <item>"
+ " <attribute name='label'>Delete frame</attribute>"
+ " <attribute name='action'>win.deleteframe</attribute>"
+ " </item>"
+ " </section>"
+ " <section>"
+ " <item>"
+ " <attribute name='label'>Slide sorter...</attribute>"
+ " <attribute name='action'>win.slidesorter</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label'>Edit stylesheet...</attribute>"
+ " <attribute name='action'>win.stylesheet</attribute>"
+ " </item>"
+ " </section>"
+ " </submenu>"
+
+ " <submenu>"
+ " <attribute name='label' translatable='yes'>Insert</attribute>"
+ " <section>"
+ " <item>"
+ " <attribute name='label'>Slide</attribute>"
+ " <attribute name='action'>win.slide</attribute>"
+ " </item>"
+ " </section>"
+ " </submenu>"
+
+ " <submenu>"
+ " <attribute name='label' translatable='yes'>Tools</attribute>"
+ " <section>"
+ " <item>"
+ " <attribute name='label'>Start slideshow</attribute>"
+ " <attribute name='action'>win.startslideshow</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label'>Slide notes...</attribute>"
+ " <attribute name='action'>win.notes</attribute>"
+ " </item>"
+ " <item>"
+ " <attribute name='label'>Presentation clock...</attribute>"
+ " <attribute name='action'>win.clock</attribute>"
" </item>"
" </section>"
" </submenu>"
diff --git a/src/narrative_window.c b/src/narrative_window.c
index ebf1ffd..1f1ac09 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -27,6 +27,7 @@
#include <gtk/gtk.h>
#include <assert.h>
+#include <string.h>
#include <stdlib.h>
#include "presentation.h"
@@ -43,8 +44,59 @@ struct _narrative_window
};
+static gint saveas_response_sig(GtkWidget *d, gint response,
+ NarrativeWindow *nw)
+{
+ if ( response == GTK_RESPONSE_ACCEPT ) {
+
+ char *filename;
+
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(d));
+
+ if ( save_presentation(nw->p, filename) ) {
+ //show_error(sw, "Failed to save presentation");
+ }
+
+ g_free(filename);
+
+ }
+
+ gtk_widget_destroy(d);
+
+ return 0;
+}
+
+
+static void saveas_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+{
+ GtkWidget *d;
+ NarrativeWindow *nw = vp;
+
+ d = gtk_file_chooser_dialog_new("Save Presentation",
+ GTK_WINDOW(nw->window),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(d),
+ TRUE);
+
+ g_signal_connect(G_OBJECT(d), "response",
+ G_CALLBACK(saveas_response_sig), nw);
+
+ gtk_widget_show_all(d);
+}
+
+
static void save_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
{
+ NarrativeWindow *nw = vp;
+
+ if ( nw->p->filename == NULL ) {
+ return saveas_sig(NULL, NULL, nw);
+ }
+
+ save_presentation(nw->p, nw->p->filename);
}
@@ -54,62 +106,47 @@ static void exportpdf_sig(GSimpleAction *action, GVariant *parameter,
}
-GActionEntry nw_entries[] = {
+static void open_slidesorter_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+{
+}
- { "save", save_sig, NULL, NULL, NULL, },
- { "exportpdf", exportpdf_sig, NULL, NULL, NULL },
-#if 0
- { "EditAction", NULL, "_Edit", NULL, NULL, NULL },
- { "SorterAction", NULL, "_Open Slide Sorter...",
- NULL, NULL, G_CALLBACK(open_slidesorter_sig) },
- { "UndoAction", GTK_STOCK_UNDO, "_Undo",
- NULL, NULL, NULL },
- { "RedoAction", GTK_STOCK_REDO, "_Redo",
- NULL, NULL, NULL },
- { "CutAction", GTK_STOCK_CUT, "Cut",
- NULL, NULL, NULL },
- { "CopyAction", GTK_STOCK_COPY, "Copy",
- NULL, NULL, NULL },
- { "PasteAction", GTK_STOCK_PASTE, "Paste",
- NULL, NULL, NULL },
- { "DeleteFrameAction", GTK_STOCK_DELETE, "Delete Frame",
- NULL, NULL, G_CALLBACK(delete_frame_sig) },
-// { "EditStyleAction", NULL, "Stylesheet...",
-// NULL, NULL, G_CALLBACK(open_stylesheet_sig) },
-
- { "InsertAction", NULL, "_Insert", NULL, NULL, NULL },
- { "NewSlideAction", GTK_STOCK_ADD, "_New Slide",
- NULL, NULL, G_CALLBACK(add_slide_sig) },
-
- { "ToolsAction", NULL, "_Tools", NULL, NULL, NULL },
- { "TSlideshowAction", GTK_STOCK_FULLSCREEN, "_Start Slideshow",
- "F5", NULL, G_CALLBACK(start_slideshow_sig) },
- { "NotesAction", NULL, "_Open slide notes",
- "F8", NULL, G_CALLBACK(open_notes_sig) },
- { "ClockAction", NULL, "_Open presentation clock",
- "F9", NULL, G_CALLBACK(open_clock_sig) },
- { "PrefsAction", GTK_STOCK_PREFERENCES, "_Preferences",
- NULL, NULL, NULL },
-
- { "HelpAction", NULL, "_Help", NULL, NULL, NULL },
- { "AboutAction", GTK_STOCK_ABOUT, "_About...",
- NULL, NULL, G_CALLBACK(about_sig) },
-
- { "SlideshowAction", GTK_STOCK_FULLSCREEN, "Start Presentation",
- NULL, NULL, G_CALLBACK(start_slideshow_sig) },
- { "AddSlideAction", GTK_STOCK_ADD, "Add Slide",
- NULL, NULL, G_CALLBACK(add_slide_sig) },
- { "ButtonFirstSlideAction", GTK_STOCK_GOTO_FIRST, "First Slide",
- NULL, NULL, G_CALLBACK(first_slide_sig) },
- { "ButtonPrevSlideAction", GTK_STOCK_GO_BACK, "Previous Slide",
- NULL, NULL, G_CALLBACK(prev_slide_sig) },
- { "ButtonNextSlideAction", GTK_STOCK_GO_FORWARD, "Next Slide",
- NULL, NULL, G_CALLBACK(next_slide_sig) },
- { "ButtonLastSlideAction", GTK_STOCK_GOTO_LAST, "Last Slide",
- NULL, NULL, G_CALLBACK(last_slide_sig) },
-#endif
+static void delete_frame_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+{
+}
+
+static void add_slide_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+{
+}
+
+
+static void start_slideshow_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+{
+}
+
+
+static void open_notes_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+{
+}
+
+
+static void open_clock_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+{
+}
+
+
+GActionEntry nw_entries[] = {
+
+ { "save", save_sig, NULL, NULL, NULL },
+ { "saveas", saveas_sig, NULL, NULL, NULL },
+ { "exportpdf", exportpdf_sig, NULL, NULL, NULL },
+ { "sorter", open_slidesorter_sig, NULL, NULL, NULL },
+ { "deleteframe", delete_frame_sig, NULL, NULL, NULL },
+ { "insert.slide", add_slide_sig, NULL, NULL, NULL },
+ { "startslideshow", start_slideshow_sig, NULL, NULL, NULL },
+ { "notes", open_notes_sig, NULL, NULL, NULL },
+ { "clock", open_clock_sig, NULL, NULL, NULL },
};
@@ -124,6 +161,24 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event,
}
+static void nw_update_titlebar(NarrativeWindow *nw)
+{
+ get_titlebar_string(nw->p);
+
+ if ( nw->p->slidewindow != NULL ) {
+
+ char *title;
+
+ title = malloc(strlen(nw->p->titlebar)+14);
+ sprintf(title, "%s - Colloquium", nw->p->titlebar);
+ gtk_window_set_title(GTK_WINDOW(nw->window), title);
+ free(title);
+
+ }
+
+}
+
+
NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *app)
{
NarrativeWindow *nw;
@@ -145,9 +200,9 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *app)
p->narrative_window = nw;
g_action_map_add_action_entries(G_ACTION_MAP(nw->window), nw_entries,
- G_N_ELEMENTS(nw_entries), nw->window);
+ G_N_ELEMENTS(nw_entries), nw);
-// update_titlebar(nw);
+ nw_update_titlebar(nw);
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add(GTK_CONTAINER(nw->window), vbox);
@@ -160,8 +215,6 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *app)
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll),
GTK_WIDGET(nw->sceditor));
- /* Size of SCEditor surface in pixels */
- /* FIXME: Somewhat arbitrary. Should come from slide itself */
sc_editor_set_size(nw->sceditor, 640, 1024);
sc_editor_set_logical_size(nw->sceditor, 640.0, 1024.0);