aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2018-10-21 18:34:56 +0200
committerThomas White <taw@bitwiz.me.uk>2018-10-21 18:34:56 +0200
commitb79dad7a05ae97dffb3f5fd9ab48ff8ffbbf6ea7 (patch)
treeb2cd9a57caf15cad4cfbd137e8d28cacce314b3d
parent2236dea3df2e651a75788334c439f1ad312709f4 (diff)
Full order of precedence for finding stylesheets
-rw-r--r--data/colloquium.gresource.xml1
-rw-r--r--data/default.ss37
-rw-r--r--src/presentation.c28
-rw-r--r--src/stylesheet.c2
4 files changed, 67 insertions, 1 deletions
diff --git a/data/colloquium.gresource.xml b/data/colloquium.gresource.xml
index 9c85e5b..819a966 100644
--- a/data/colloquium.gresource.xml
+++ b/data/colloquium.gresource.xml
@@ -6,6 +6,7 @@
<file>stylesheeteditor.ui</file>
<file>demo.sc</file>
<file>demo.ss</file>
+ <file>default.ss</file>
<file>canvas.png</file>
<file>alpha_warning.svg</file>
<file>colloquium.svg</file>
diff --git a/data/default.ss b/data/default.ss
new file mode 100644
index 0000000..5ea74f6
--- /dev/null
+++ b/data/default.ss
@@ -0,0 +1,37 @@
+{
+ "narrative": {
+ "font": "Cantarell Regular 16",
+ "fgcol": "#222222",
+ "pad": "10,10,10,10",
+ "paraspace": "0,0,10,10",
+ "bgcol": "#ffffff"
+ },
+
+ "slide": {
+ "size": "1280x720",
+ "bggradv": "#333333,#000055",
+ "frame": {
+ "font": "Cantarell Regular 14",
+ "pad": "0,0,0,0",
+ "fgcol": "#c5c5c5",
+ "bgcol": "#ffffff00",
+ "paraspace": "5,5,5,5"
+ },
+ "slidetitle": {
+ "geometry": "1fx90u+0+0",
+ "pad": "20,20,20,20",
+ "fgcol": "#eeeeee",
+ "font": "Cantarell Regular 36",
+ "bgcol": "#ffffff00"
+ },
+ "prestitle": {
+ "geometry": "1fx140u+0+0",
+ "pad": "20,20,20,20",
+ "fgcol": "#eeeeee",
+ "font": "Cantarell Regular 64",
+ "alignment": "center",
+ "bgcol": "#ffffff00"
+ },
+ "_comment": "Add footer, credit and bp"
+ }
+}
diff --git a/src/presentation.c b/src/presentation.c
index a33a541..686c97d 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -246,6 +246,7 @@ int load_presentation(struct presentation *p, GFile *file)
int r = 0;
char *everything;
GFile *ssfile;
+ GFile *parent;
gchar *ssuri;
assert(p->completely_empty);
@@ -269,6 +270,8 @@ int load_presentation(struct presentation *p, GFile *file)
}
p->stylesheet = NULL;
+
+ /* First choice: /same/directory/<presentation>.ss */
ssuri = g_file_get_uri(file);
if ( ssuri != NULL ) {
size_t l = strlen(ssuri);
@@ -280,12 +283,35 @@ int load_presentation(struct presentation *p, GFile *file)
g_free(ssuri);
}
}
+
+ /* Second choice: /same/directory/stylesheet.ss */
+ if ( p->stylesheet == NULL ) {
+ parent = g_file_get_parent(file);
+ if ( parent != NULL ) {
+ ssfile = g_file_get_child(parent, "stylesheet.ss");
+ if ( ssfile != NULL ) {
+ p->stylesheet = stylesheet_load(ssfile);
+ g_object_unref(ssfile);
+ }
+ }
+ }
+
+ /* Third choice: <cwd>/stylesheet.ss */
+ if ( p->stylesheet == NULL ) {
+ ssfile = g_file_new_for_path("./stylesheet.ss");
+ p->stylesheet = stylesheet_load(ssfile);
+ g_object_unref(ssfile);
+ }
+
+ /* Fourth choice: internal default stylesheet */
if ( p->stylesheet == NULL ) {
- ssfile = g_file_new_for_path("./stylesheet.json");
+ ssfile = g_file_new_for_uri("resource:///uk/me/bitwiz/Colloquium/default.ss");
p->stylesheet = stylesheet_load(ssfile);
g_object_unref(ssfile);
}
+ /* Last resort is NULL stylesheet and SCInterpreter's defaults */
+
set_slide_size_from_stylesheet(p);
assert(p->uri == NULL);
diff --git a/src/stylesheet.c b/src/stylesheet.c
index 020107e..ed84905 100644
--- a/src/stylesheet.c
+++ b/src/stylesheet.c
@@ -49,6 +49,8 @@ Stylesheet *stylesheet_load(GFile *file)
char *everything;
gsize len;
+ printf("Trying stylesheet '%s'\n", g_file_get_uri(file));
+
ss = calloc(1, sizeof(Stylesheet));
if ( ss == NULL ) return NULL;