aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-01-24 14:58:45 +0100
committerThomas White <taw@physics.org>2020-01-24 14:58:45 +0100
commitc84cdfa1e3d3060e64c6d1d7b332a13024c6da9e (patch)
tree07dab818b960b6d561ca12b128806686c5ce653c
parent6fd2388d71eb64ade70106a14617a46ee3366bfc (diff)
Insert bullet points
-rw-r--r--data/menus.ui16
-rw-r--r--libstorycode/gtk/gtknarrativeview.c56
-rw-r--r--libstorycode/gtk/gtknarrativeview.h1
-rw-r--r--src/narrative_window.c10
4 files changed, 73 insertions, 10 deletions
diff --git a/data/menus.ui b/data/menus.ui
index 019bbed..988f88a 100644
--- a/data/menus.ui
+++ b/data/menus.ui
@@ -117,6 +117,22 @@
<attribute name='label' translatable='yes'>Slide</attribute>
<attribute name='action'>win.slide</attribute>
</item>
+ <item>
+ <attribute name='label' translatable='yes'>Bullet point</attribute>
+ <attribute name='action'>win.bp</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>Presentation title</attribute>
+ <attribute name='action'>win.prestitle</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>Start of segment</attribute>
+ <attribute name='action'>win.segstart</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>End of segment</attribute>
+ <attribute name='action'>win.segend</attribute>
+ </item>
</section>
<section>
<item>
diff --git a/libstorycode/gtk/gtknarrativeview.c b/libstorycode/gtk/gtknarrativeview.c
index 24e4949..11d17c0 100644
--- a/libstorycode/gtk/gtknarrativeview.c
+++ b/libstorycode/gtk/gtknarrativeview.c
@@ -1304,27 +1304,35 @@ void gtk_narrative_view_set_cursor_para(GtkNarrativeView *e, signed int pos)
}
-void gtk_narrative_view_add_slide_at_cursor(GtkNarrativeView *e)
+int maybe_split_para(GtkNarrativeView *e)
{
- Slide *s;
-
- s = slide_new();
- if ( s == NULL ) return;
-
if ( narrative_item_is_text(e->n, e->cpos.para) ) {
size_t off = narrative_pos_trail_to_offset(e->n, e->cpos.para,
e->cpos.pos, e->cpos.trail);
if ( (off > 0) && (off < gtknv_end_offset_of_para(e->n, e->cpos.para)) ) {
narrative_split_item(e->n, e->cpos.para, off);
- narrative_insert_slide(e->n, s, e->cpos.para+1);
+ return e->cpos.para+1;
} else if ( off == 0 ) {
- narrative_insert_slide(e->n, s, e->cpos.para);
+ return e->cpos.para;
} else {
- narrative_insert_slide(e->n, s, e->cpos.para+1);
+ return e->cpos.para+1;
}
} else {
- narrative_insert_slide(e->n, s, e->cpos.para+1);
+ return e->cpos.para+1;
}
+}
+
+
+void gtk_narrative_view_add_slide_at_cursor(GtkNarrativeView *e)
+{
+ Slide *s;
+ int insert_pos;
+
+ s = slide_new();
+ if ( s == NULL ) return;
+
+ insert_pos = maybe_split_para(e);
+ narrative_insert_slide(e->n, insert_pos, s);
rewrap_range(e, e->cpos.para, e->cpos.para+2);
e->cpos.para++;
@@ -1337,6 +1345,34 @@ void gtk_narrative_view_add_slide_at_cursor(GtkNarrativeView *e)
}
+void gtk_narrative_view_add_bp_at_cursor(GtkNarrativeView *e)
+{
+ int insert_pos;
+ struct text_run *runs;
+
+ runs = malloc(sizeof(struct text_run));
+ if ( runs == NULL ) return;
+
+ runs[0].text = strdup("");
+ runs[0].type = TEXT_RUN_NORMAL;
+ if ( runs[0].text == NULL ) {
+ free(runs);
+ return;
+ }
+
+ insert_pos = maybe_split_para(e);
+ narrative_insert_bp(e->n, insert_pos, runs, 1);
+
+ rewrap_range(e, e->cpos.para, e->cpos.para+2);
+ e->cpos.para++;
+ e->cpos.pos = 0;
+ e->cpos.trail = 0;
+ update_size(e);
+ check_cursor_visible(e);
+ gtknv_emit_change_sig(e);
+ gtknv_redraw(e);
+}
+
void gtk_narrative_view_redraw(GtkNarrativeView *e)
{
e->rewrap_needed = 1;
diff --git a/libstorycode/gtk/gtknarrativeview.h b/libstorycode/gtk/gtknarrativeview.h
index 2a2b0e9..73cc19e 100644
--- a/libstorycode/gtk/gtknarrativeview.h
+++ b/libstorycode/gtk/gtknarrativeview.h
@@ -113,6 +113,7 @@ extern void gtk_narrative_view_set_para_highlight(GtkNarrativeView *e, int para_
extern int gtk_narrative_view_get_cursor_para(GtkNarrativeView *e);
extern void gtk_narrative_view_set_cursor_para(GtkNarrativeView *e, signed int pos);
extern void gtk_narrative_view_add_slide_at_cursor(GtkNarrativeView *e);
+extern void gtk_narrative_view_add_bp_at_cursor(GtkNarrativeView *e);
extern void gtk_narrative_view_redraw(GtkNarrativeView *e);
diff --git a/src/narrative_window.c b/src/narrative_window.c
index 9a06a07..e414556 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -326,6 +326,15 @@ static void add_slide_sig(GSimpleAction *action, GVariant *parameter,
update_titlebar(nw);
}
+static void add_bp_sig(GSimpleAction *action, GVariant *parameter,
+ gpointer vp)
+{
+ NarrativeWindow *nw = vp;
+ gtk_narrative_view_add_bp_at_cursor(GTK_NARRATIVE_VIEW(nw->nv));
+ narrative_set_unsaved(nw->n);
+ update_titlebar(nw);
+}
+
static void set_clock_pos(NarrativeWindow *nw)
{
@@ -670,6 +679,7 @@ GActionEntry nw_entries[] = {
{ "save", save_sig, NULL, NULL, NULL },
{ "saveas", saveas_sig, NULL, NULL, NULL },
{ "slide", add_slide_sig, NULL, NULL, NULL },
+ { "bp", add_bp_sig, NULL, NULL, NULL },
{ "loadstylesheet", load_ss_sig, NULL, NULL, NULL },
{ "stylesheet", edit_ss_sig, NULL, NULL, NULL },
{ "startslideshow", start_slideshow_sig, NULL, NULL, NULL },