aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-05-03 22:06:56 +0200
committerThomas White <taw@bitwiz.me.uk>2019-05-03 22:06:56 +0200
commit36fae6750885e2b6458f61369b23c26fb6b75bf9 (patch)
treeb9d82260430f92bc612c25cb13759979bde2553c
parentcea453dee6871c91a570b038cf9f286bfce1a0ce (diff)
Fix crashes caused by toolbar paragraph motion buttons
-rw-r--r--libstorycode/gtk/gtknarrativeview.c1
-rw-r--r--src/narrative_window.c11
2 files changed, 9 insertions, 3 deletions
diff --git a/libstorycode/gtk/gtknarrativeview.c b/libstorycode/gtk/gtknarrativeview.c
index 58cbd8e..48ef91f 100644
--- a/libstorycode/gtk/gtknarrativeview.c
+++ b/libstorycode/gtk/gtknarrativeview.c
@@ -1192,6 +1192,7 @@ void gtk_narrative_view_set_cursor_para(GtkNarrativeView *e, signed int pos)
double h;
int i;
+ if ( pos < 0 ) pos = e->n->n_items-1;
e->cpos.para = pos;
e->cpos.pos = 0;
e->cpos.trail = 0;
diff --git a/src/narrative_window.c b/src/narrative_window.c
index 3ef43af..d90913b 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -138,6 +138,8 @@ static void update_toolbar(NarrativeWindow *nw)
{
int cur_para, n_para;
+ if ( nw->show == NULL ) return;
+
cur_para = gtk_narrative_view_get_cursor_para(GTK_NARRATIVE_VIEW(nw->nv));
if ( cur_para == 0 ) {
gtk_widget_set_sensitive(GTK_WIDGET(nw->bfirst), FALSE);
@@ -374,7 +376,7 @@ static void ss_next_para(SCSlideshow *ss, void *vp)
gtk_narrative_view_set_cursor_para(nv, gtk_narrative_view_get_cursor_para(nv)+1);
/* If we only have one monitor, skip to next slide */
- if ( ss->single_monitor && !nw->show_no_slides ) {
+ if ( ss != NULL && ss->single_monitor && !nw->show_no_slides ) {
int i;
for ( i=gtk_narrative_view_get_cursor_para(nv); i<n_paras; i++ )
{
@@ -387,7 +389,7 @@ static void ss_next_para(SCSlideshow *ss, void *vp)
pr_clock_set_pos(nw->pr_clock, gtk_narrative_view_get_cursor_para(nv), n_paras);
ns = narrative_get_slide(nw->n, gtk_narrative_view_get_cursor_para(nv));
- if ( ns != NULL ) {
+ if ( nw->show != NULL && ns != NULL ) {
sc_slideshow_set_slide(nw->show, ns);
}
update_toolbar(nw);
@@ -797,7 +799,10 @@ NarrativeWindow *narrative_window_new(Narrative *n, GFile *file, GApplication *p
gtk_actionable_set_action_name(GTK_ACTIONABLE(nw->blast),
"win.last");
- update_toolbar(nw);
+ gtk_widget_set_sensitive(GTK_WIDGET(nw->bfirst), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(nw->bprev), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(nw->bnext), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(nw->blast), FALSE);
scroll = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),