aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-03-15 23:37:27 +0100
committerThomas White <taw@bitwiz.me.uk>2019-03-15 23:37:27 +0100
commit0e1f2f49f4d3b02901c8ba291a8ffb2605418db4 (patch)
treededb4e864a02cb8181f2b44d13891bafc91a12d4 /src
parent44f874ed89b364bc0b60b35572f64fae44154733 (diff)
Initial GtkSlideView
Diffstat (limited to 'src')
-rw-r--r--src/narrative_window.c17
-rw-r--r--src/pdfstorycode.c4
-rw-r--r--src/slide_window.c244
-rw-r--r--src/slide_window.h35
4 files changed, 295 insertions, 5 deletions
diff --git a/src/narrative_window.c b/src/narrative_window.c
index b6d8514..7e635b5 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -38,22 +38,22 @@
#include "colloquium.h"
#include "narrative_window.h"
+#include "slide_window.h"
//#include "testcard.h"
//#include "pr_clock.h"
//#include "print.h"
//#include "stylesheet_editor.h"
typedef struct _ss SCSlideshow; /* FIXME placeholder */
-typedef struct _sw SlideWindow; /* FIXME placeholder */
typedef struct _pc PRClock; /* FIXME placeholder */
struct _narrative_window
{
- GtkWidget *window;
+ GtkWidget *window;
GtkToolItem *bfirst;
GtkToolItem *bprev;
GtkToolItem *bnext;
GtkToolItem *blast;
- GtkNarrativeView *nv;
+ GtkWidget *nv;
GApplication *app;
Presentation *p;
GFile *file;
@@ -465,6 +465,15 @@ static gboolean nw_destroy_sig(GtkWidget *da, NarrativeWindow *nw)
}
+static gboolean nw_double_click_sig(GtkWidget *da, gpointer *pslide,
+ NarrativeWindow *nw)
+{
+ Slide *slide = (Slide *)pslide;
+ slide_window_open(nw->p, slide, nw->app);
+ return FALSE;
+}
+
+
static gboolean nw_key_press_sig(GtkWidget *da, GdkEventKey *event,
NarrativeWindow *nw)
{
@@ -768,6 +777,8 @@ NarrativeWindow *narrative_window_new(Presentation *p, GApplication *papp)
G_CALLBACK(nw_key_press_sig), nw);
g_signal_connect(G_OBJECT(nw->window), "destroy",
G_CALLBACK(nw_destroy_sig), nw);
+ g_signal_connect(G_OBJECT(nw->nv), "slide-double-clicked",
+ G_CALLBACK(nw_double_click_sig), nw);
gtk_window_set_default_size(GTK_WINDOW(nw->window), 768, 768);
gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0);
diff --git a/src/pdfstorycode.c b/src/pdfstorycode.c
index 92e2809..566f924 100644
--- a/src/pdfstorycode.c
+++ b/src/pdfstorycode.c
@@ -61,12 +61,12 @@ static int render_slides_to_pdf(Presentation *p, ImageStore *is, const char *fil
cr = cairo_create(surf);
pc = pango_cairo_create_context(cr);
- for ( i=0; i<presentation_num_slides(p); i++ )
+ for ( i=0; i<presentation_get_num_slides(p); i++ )
{
Slide *s;
double log_w, log_h;
- s = presentation_slide(p, i);
+ s = presentation_get_slide_by_number(p, i);
slide_get_logical_size(s, presentation_get_stylesheet(p),
&log_w, &log_h);
diff --git a/src/slide_window.c b/src/slide_window.c
new file mode 100644
index 0000000..b6c60da
--- /dev/null
+++ b/src/slide_window.c
@@ -0,0 +1,244 @@
+/*
+ * slide_window.c
+ *
+ * Copyright © 2013-2018 Thomas White <taw@bitwiz.org.uk>
+ *
+ * This file is part of Colloquium.
+ *
+ * Colloquium 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 <gtk/gtk.h>
+#include <assert.h>
+#include <gdk/gdkkeysyms.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <math.h>
+
+#include <presentation.h>
+#include <slide.h>
+#include <gtkslideview.h>
+
+#include "colloquium.h"
+#include "slide_window.h"
+
+
+struct _slidewindow
+{
+ GtkWidget *window;
+ Presentation *p;
+ Slide *slide;
+ GtkWidget *sv;
+};
+
+
+static void insert_slidetitle_sig(GSimpleAction *action, GVariant *parameter,
+ gpointer vp)
+{
+ SlideWindow *sw = vp;
+ char **text = malloc(sizeof(char *));
+ *text = strdup("Slide title");
+ slide_add_slidetitle(sw->slide, text, 1);
+}
+
+
+static void paste_sig(GSimpleAction *action, GVariant *parameter,
+ gpointer vp)
+{
+ //SlideWindow *sw = vp;
+ //sc_editor_paste(sw->sceditor);
+}
+
+
+static void copy_frame_sig(GSimpleAction *action, GVariant *parameter,
+ gpointer vp)
+{
+ //SlideWindow *sw = vp;
+ //sc_editor_copy_selected_frame(sw->sceditor);
+}
+
+
+static void delete_frame_sig(GSimpleAction *action, GVariant *parameter,
+ gpointer vp)
+{
+ //SlideWindow *sw = vp;
+ //sc_editor_delete_selected_frame(sw->sceditor);
+}
+
+
+/* Change the editor's slide to "np" */
+static void change_edit_slide(SlideWindow *sw, Slide *np)
+{
+ gtk_slide_view_set_slide(sw->sv, np);
+ sw->slide = np;
+}
+
+
+static void change_slide_first(SlideWindow *sw)
+{
+ Slide *s = presentation_get_slide_by_number(sw->p, 0);
+ if ( s != NULL ) change_edit_slide(sw, s);
+}
+
+
+static void change_slide_backwards(SlideWindow *sw)
+{
+ int slide_n = presentation_get_slide_number(sw->p, sw->slide);
+ if ( slide_n > 0 ) {
+ Slide *s = presentation_get_slide_by_number(sw->p, slide_n-1);
+ change_edit_slide(sw, s);
+ }
+}
+
+
+static void change_slide_forwards(SlideWindow *sw)
+{
+ int slide_n = presentation_get_slide_number(sw->p, sw->slide);
+ Slide *s = presentation_get_slide_by_number(sw->p, slide_n+1);
+ if ( s != NULL ) change_edit_slide(sw, s);
+}
+
+
+static void change_slide_last(SlideWindow *sw)
+{
+ int slide_n = presentation_get_num_slides(sw->p);
+ Slide *s = presentation_get_slide_by_number(sw->p, slide_n);
+ if ( s != NULL ) change_edit_slide(sw, s);
+}
+
+
+static void first_slide_sig(GSimpleAction *action, GVariant *parameter,
+ gpointer vp)
+{
+ SlideWindow *sw = vp;
+ change_slide_first(sw);
+}
+
+
+static void prev_slide_sig(GSimpleAction *action, GVariant *parameter,
+ gpointer vp)
+{
+ SlideWindow *sw = vp;
+ change_slide_backwards(sw);
+}
+
+
+static void next_slide_sig(GSimpleAction *action, GVariant *parameter,
+ gpointer vp)
+{
+ SlideWindow *sw = vp;
+ change_slide_forwards(sw);
+}
+
+
+static void last_slide_sig(GSimpleAction *action, GVariant *parameter,
+ gpointer vp)
+{
+ SlideWindow *sw = vp;
+ change_slide_last(sw);
+}
+
+
+static gboolean sw_close_sig(GtkWidget *w, SlideWindow *sw)
+{
+ //narrative_window_sw_closed(sw->p->narrative_window, sw);
+ return FALSE;
+}
+
+
+static gboolean sw_key_press_sig(GtkWidget *da, GdkEventKey *event,
+ SlideWindow *sw)
+{
+ switch ( event->keyval ) {
+
+ case GDK_KEY_Page_Up :
+ change_slide_backwards(sw);
+ break;
+
+ case GDK_KEY_Page_Down :
+ change_slide_forwards(sw);
+ break;
+
+ }
+
+ return FALSE;
+}
+
+
+static void about_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+{
+ SlideWindow *sw = vp;
+ open_about_dialog(sw->window);
+}
+
+
+GActionEntry sw_entries[] = {
+
+ { "about", about_sig, NULL, NULL, NULL },
+ { "paste", paste_sig, NULL, NULL, NULL },
+ { "copyframe", copy_frame_sig, NULL, NULL, NULL },
+ { "deleteframe", delete_frame_sig, NULL, NULL, NULL },
+ { "first", first_slide_sig, NULL, NULL, NULL },
+ { "prev", prev_slide_sig, NULL, NULL, NULL },
+ { "next", next_slide_sig, NULL, NULL, NULL },
+ { "last", last_slide_sig, NULL, NULL, NULL },
+ { "slidetitle", insert_slidetitle_sig, NULL, NULL, NULL },
+};
+
+
+extern SlideWindow *slide_window_open(Presentation *p, Slide *slide,
+ GApplication *papp)
+{
+ GtkWidget *window;
+ SlideWindow *sw;
+ double w, h;
+ Colloquium *app = COLLOQUIUM(papp);
+
+ sw = calloc(1, sizeof(SlideWindow));
+ if ( sw == NULL ) return NULL;
+
+ window = gtk_application_window_new(GTK_APPLICATION(app));
+ gtk_window_set_role(GTK_WINDOW(window), "slide");
+ sw->window = window;
+ sw->p = p;
+
+ g_action_map_add_action_entries(G_ACTION_MAP(window), sw_entries,
+ G_N_ELEMENTS(sw_entries), sw);
+
+ g_signal_connect(G_OBJECT(window), "destroy",
+ G_CALLBACK(sw_close_sig), sw);
+
+ sw->sv = gtk_slide_view_new(p, slide);
+
+ g_signal_connect(G_OBJECT(sw->sv), "key-press-event",
+ G_CALLBACK(sw_key_press_sig), sw);
+
+ slide_get_logical_size(slide, presentation_get_stylesheet(p), &w, &h);
+ gtk_window_set_default_size(GTK_WINDOW(window), w, h);
+
+ gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(sw->sv));
+
+ gtk_window_set_resizable(GTK_WINDOW(sw->window), TRUE);
+
+ gtk_widget_show_all(window);
+
+ return sw;
+}
diff --git a/src/slide_window.h b/src/slide_window.h
new file mode 100644
index 0000000..f59fad1
--- /dev/null
+++ b/src/slide_window.h
@@ -0,0 +1,35 @@
+/*
+ * slide_window.h
+ *
+ * Copyright © 2013-2019 Thomas White <taw@bitwiz.org.uk>
+ *
+ * This file is part of Colloquium.
+ *
+ * Colloquium 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 SLIDEWINDOW_H
+#define SLIDEWINDOW_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+typedef struct _slidewindow SlideWindow;
+
+extern SlideWindow *slide_window_open(Presentation *p, Slide *slide,
+ GApplication *papp);
+
+#endif /* SLIDEWINDOW_H */