aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-03-11 16:56:56 +0100
committerThomas White <taw@physics.org>2018-03-11 16:57:17 +0100
commit6158d0d7411a6718fab01873109067b227bfa1b8 (patch)
tree63a534c6f18c1d191bc8e77c755ea64eca6feb50
parent01c0a135250841ed2a5f748432dae8f0052c6874 (diff)
Avoid creating extra ImageStores
-rw-r--r--src/frame.c5
-rw-r--r--src/narrative_window.c1
-rw-r--r--src/sc_editor.c11
-rw-r--r--src/sc_editor.h1
-rw-r--r--src/slide_window.c1
5 files changed, 18 insertions, 1 deletions
diff --git a/src/frame.c b/src/frame.c
index abdebe0..7099209 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -505,6 +505,11 @@ void add_image_para(struct frame *fr, SCBlock *scblock, const char *filename,
Paragraph *pnew;
int wi, hi;
+ if ( is == NULL ) {
+ fprintf(stderr, "Adding image without ImageStore!\n");
+ return;
+ }
+
pnew = create_paragraph(fr);
if ( pnew == NULL ) {
fprintf(stderr, "Failed to add image paragraph\n");
diff --git a/src/narrative_window.c b/src/narrative_window.c
index 968ea5c..3bd066f 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -820,6 +820,7 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *papp
sc_callback_list_add_callback(cbl, "sthumb", create_thumbnail,
render_thumbnail, click_thumbnail, p);
sc_editor_set_callbacks(nw->sceditor, cbl);
+ sc_editor_set_imagestore(nw->sceditor, p->is);
toolbar = gtk_toolbar_new();
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
diff --git a/src/sc_editor.c b/src/sc_editor.c
index cec0186..3972f02 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -2041,6 +2041,15 @@ void sc_editor_set_scale(SCEditor *e, int scale)
}
+void sc_editor_set_imagestore(SCEditor *e, ImageStore *is)
+{
+ if ( e->is != NULL ) {
+ fprintf(stderr, "WARNING: Changing imagestore\n");
+ }
+ e->is = is;
+}
+
+
SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets,
PangoLanguage *lang, const char *storename)
{
@@ -2057,7 +2066,7 @@ SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets,
sceditor->log_h = 100;
sceditor->border_offs_x = 0;
sceditor->border_offs_y = 0;
- sceditor->is = imagestore_new(storename);
+ sceditor->is = NULL;
sceditor->slidenum = 0;
sceditor->min_border = 0.0;
sceditor->top_editable = 0;
diff --git a/src/sc_editor.h b/src/sc_editor.h
index ea5b8f8..cef61d2 100644
--- a/src/sc_editor.h
+++ b/src/sc_editor.h
@@ -193,6 +193,7 @@ extern void sc_editor_delete_selected_frame(SCEditor *e);
extern void sc_editor_remove_cursor(SCEditor *e);
extern SCBlock *split_paragraph_at_cursor(SCEditor *e);
+extern void sc_editor_set_imagestore(SCEditor *e, ImageStore *is);
extern void sc_editor_set_para_highlight(SCEditor *e, int para_highlight);
extern int sc_editor_get_cursor_para(SCEditor *e);
extern void *sc_editor_get_cursor_bvp(SCEditor *e);
diff --git a/src/slide_window.c b/src/slide_window.c
index 8e9918b..e6d0970 100644
--- a/src/slide_window.c
+++ b/src/slide_window.c
@@ -254,6 +254,7 @@ SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks,
colloquium_get_imagestore(app));
sc_editor_set_slidenum(sw->sceditor, slide_number(sw->p, scblocks));
sc_editor_set_scale(sw->sceditor, 1);
+ sc_editor_set_imagestore(sw->sceditor, p->is);
// scroll = gtk_scrolled_window_new(NULL, NULL);
// gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),