From ef49ac2a7919d9284e2db4c34b5fccf3d636f72e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 22 Apr 2018 12:18:28 +0200 Subject: Add preliminary stylesheet editor --- data/colloquium.gresource.xml | 1 + data/stylesheeteditor.ui | 1085 +++++++++++++++++++++++++++++++++++++++++ meson.build | 1 + po/POTFILES | 1 + po/colloquium.pot | 143 +++++- po/de.po | 143 +++++- src/colloquium.c | 1 + src/narrative_window.c | 14 + src/stylesheet_editor.c | 79 +++ src/stylesheet_editor.h | 73 +++ 10 files changed, 1497 insertions(+), 44 deletions(-) create mode 100644 data/stylesheeteditor.ui create mode 100644 src/stylesheet_editor.c create mode 100644 src/stylesheet_editor.h diff --git a/data/colloquium.gresource.xml b/data/colloquium.gresource.xml index 5c8b4b0..369144b 100644 --- a/data/colloquium.gresource.xml +++ b/data/colloquium.gresource.xml @@ -3,6 +3,7 @@ sky.png menus.ui + stylesheeteditor.ui demo.sc canvas.png alpha_warning.svg diff --git a/data/stylesheeteditor.ui b/data/stylesheeteditor.ui new file mode 100644 index 0000000..514e01c --- /dev/null +++ b/data/stylesheeteditor.ui @@ -0,0 +1,1085 @@ + + + + + + + diff --git a/meson.build b/meson.build index 24f54ed..a2e3fb2 100644 --- a/meson.build +++ b/meson.build @@ -44,6 +44,7 @@ executable('colloquium', 'src/print.c', 'src/sc_parse.c', 'src/utils.c', + 'src/stylesheet_editor.c', ], gresources, dependencies : [gtkdep, mdep], diff --git a/po/POTFILES b/po/POTFILES index 0d736d9..ff4049c 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -15,3 +15,4 @@ src/slide_window.c src/testcard.c src/utils.c data/menus.ui +data/stylesheeteditor.ui diff --git a/po/colloquium.pot b/po/colloquium.pot index 67114d4..ac51e51 100644 --- a/po/colloquium.pot +++ b/po/colloquium.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: colloquium\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-04-22 12:15+0200\n" +"POT-Creation-Date: 2018-04-22 23:21+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -40,12 +40,12 @@ msgstr "" msgid "Open Presentation" msgstr "" -#: src/colloquium.c:198 src/narrative_window.c:129 src/narrative_window.c:341 -#: src/narrative_window.c:508 +#: src/colloquium.c:198 src/narrative_window.c:130 src/narrative_window.c:340 +#: src/narrative_window.c:507 msgid "_Cancel" msgstr "" -#: src/colloquium.c:199 src/narrative_window.c:342 +#: src/colloquium.c:199 src/narrative_window.c:341 msgid "_Open" msgstr "" @@ -391,76 +391,76 @@ msgstr "" msgid "%s :\n" msgstr "" -#: src/narrative_window.c:108 +#: src/narrative_window.c:109 msgid "Failed to save presentation" msgstr "" -#: src/narrative_window.c:126 +#: src/narrative_window.c:127 msgid "Save Presentation" msgstr "" -#: src/narrative_window.c:130 data/menus.ui:24 +#: src/narrative_window.c:131 data/menus.ui:24 msgid "_Save" msgstr "" -#: src/narrative_window.c:173 +#: src/narrative_window.c:174 #, c-format msgid "Not a slide!\n" msgstr "" -#: src/narrative_window.c:300 +#: src/narrative_window.c:301 #, c-format msgid "Not a style sheet\n" msgstr "" -#: src/narrative_window.c:303 +#: src/narrative_window.c:304 #, c-format msgid "Failed to load\n" msgstr "" -#: src/narrative_window.c:338 +#: src/narrative_window.c:337 msgid "Load stylesheet" msgstr "" -#: src/narrative_window.c:372 +#: src/narrative_window.c:371 #, c-format msgid "Failed to split paragraph\n" msgstr "" -#: src/narrative_window.c:505 +#: src/narrative_window.c:504 msgid "Export PDF" msgstr "" -#: src/narrative_window.c:509 +#: src/narrative_window.c:508 msgid "_Export" msgstr "" -#: src/narrative_window.c:803 +#: src/narrative_window.c:802 #, c-format msgid "Narrative window is already open!\n" msgstr "" -#: src/narrative_window.c:853 data/menus.ui:134 +#: src/narrative_window.c:852 data/menus.ui:134 msgid "Start slideshow" msgstr "" -#: src/narrative_window.c:864 +#: src/narrative_window.c:863 msgid "Add slide" msgstr "" -#: src/narrative_window.c:874 +#: src/narrative_window.c:873 msgid "First slide" msgstr "" -#: src/narrative_window.c:881 +#: src/narrative_window.c:880 msgid "Previous slide" msgstr "" -#: src/narrative_window.c:888 +#: src/narrative_window.c:887 msgid "Next slide" msgstr "" -#: src/narrative_window.c:895 +#: src/narrative_window.c:894 msgid "Last slide" msgstr "" @@ -969,7 +969,7 @@ msgstr "" msgid "Slide" msgstr "" -#: data/menus.ui:124 +#: data/menus.ui:124 data/stylesheeteditor.ui:822 data/stylesheeteditor.ui:902 msgid "Slide title" msgstr "" @@ -1004,3 +1004,102 @@ msgstr "" #: data/menus.ui:192 msgid "_About" msgstr "" + +#: data/stylesheeteditor.ui:7 +msgid "Stylesheet editor" +msgstr "" + +#: data/stylesheeteditor.ui:77 +msgid "" +"This style will be used in the narrative editor and for slides unless " +"overridden" +msgstr "" + +#: data/stylesheeteditor.ui:95 data/stylesheeteditor.ui:471 +msgid "Text:" +msgstr "" + +#: data/stylesheeteditor.ui:146 data/stylesheeteditor.ui:522 +msgid "Background:" +msgstr "" + +#: data/stylesheeteditor.ui:160 data/stylesheeteditor.ui:535 +msgid "Flat colour" +msgstr "" + +#: data/stylesheeteditor.ui:161 data/stylesheeteditor.ui:536 +msgid "Horizontal gradient" +msgstr "" + +#: data/stylesheeteditor.ui:162 data/stylesheeteditor.ui:537 +msgid "Vertical gradient" +msgstr "" + +#: data/stylesheeteditor.ui:227 data/stylesheeteditor.ui:603 +msgid "Top:" +msgstr "" + +#: data/stylesheeteditor.ui:264 data/stylesheeteditor.ui:640 +msgid "Left:" +msgstr "" + +#: data/stylesheeteditor.ui:301 data/stylesheeteditor.ui:678 +msgid "Right:" +msgstr "" + +#: data/stylesheeteditor.ui:327 data/stylesheeteditor.ui:704 +msgid "Bottom:" +msgstr "" + +#: data/stylesheeteditor.ui:364 data/stylesheeteditor.ui:740 +msgid "Paragraph spacing" +msgstr "" + +#: data/stylesheeteditor.ui:402 data/stylesheeteditor.ui:778 +#: data/stylesheeteditor.ui:858 data/stylesheeteditor.ui:938 +msgid "Storycode" +msgstr "" + +#: data/stylesheeteditor.ui:419 +msgid "Default style" +msgstr "" + +#: data/stylesheeteditor.ui:439 +msgid "This style will be used in the narrative editor" +msgstr "" + +#: data/stylesheeteditor.ui:450 +msgid "Use default style" +msgstr "" + +#: data/stylesheeteditor.ui:798 +msgid "Narrative style" +msgstr "" + +#: data/stylesheeteditor.ui:821 data/stylesheeteditor.ui:901 +msgid "Presentation title" +msgstr "" + +#: data/stylesheeteditor.ui:878 +msgid "Style definitions" +msgstr "" + +#: data/stylesheeteditor.ui:958 +msgid "Templates" +msgstr "" + +#: data/stylesheeteditor.ui:984 +msgid "Slide width:" +msgstr "" + +#: data/stylesheeteditor.ui:1010 +msgid "Slide height:" +msgstr "" + +#: data/stylesheeteditor.ui:1036 +msgid "(arbitrary units)" +msgstr "" + +#: data/stylesheeteditor.ui:1064 +msgid "Properties" +msgstr "" diff --git a/po/de.po b/po/de.po index 7e019a0..4ef8954 100644 --- a/po/de.po +++ b/po/de.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: colloquium\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-04-22 12:15+0200\n" +"POT-Creation-Date: 2018-04-22 23:21+0200\n" "PO-Revision-Date: 2018-04-10 23:10+0200\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -40,12 +40,12 @@ msgstr "" msgid "Open Presentation" msgstr "" -#: src/colloquium.c:198 src/narrative_window.c:129 src/narrative_window.c:341 -#: src/narrative_window.c:508 +#: src/colloquium.c:198 src/narrative_window.c:130 src/narrative_window.c:340 +#: src/narrative_window.c:507 msgid "_Cancel" msgstr "" -#: src/colloquium.c:199 src/narrative_window.c:342 +#: src/colloquium.c:199 src/narrative_window.c:341 msgid "_Open" msgstr "" @@ -391,76 +391,76 @@ msgstr "" msgid "%s :\n" msgstr "" -#: src/narrative_window.c:108 +#: src/narrative_window.c:109 msgid "Failed to save presentation" msgstr "" -#: src/narrative_window.c:126 +#: src/narrative_window.c:127 msgid "Save Presentation" msgstr "" -#: src/narrative_window.c:130 data/menus.ui:24 +#: src/narrative_window.c:131 data/menus.ui:24 msgid "_Save" msgstr "" -#: src/narrative_window.c:173 +#: src/narrative_window.c:174 #, c-format msgid "Not a slide!\n" msgstr "" -#: src/narrative_window.c:300 +#: src/narrative_window.c:301 #, c-format msgid "Not a style sheet\n" msgstr "" -#: src/narrative_window.c:303 +#: src/narrative_window.c:304 #, c-format msgid "Failed to load\n" msgstr "" -#: src/narrative_window.c:338 +#: src/narrative_window.c:337 msgid "Load stylesheet" msgstr "" -#: src/narrative_window.c:372 +#: src/narrative_window.c:371 #, c-format msgid "Failed to split paragraph\n" msgstr "" -#: src/narrative_window.c:505 +#: src/narrative_window.c:504 msgid "Export PDF" msgstr "" -#: src/narrative_window.c:509 +#: src/narrative_window.c:508 msgid "_Export" msgstr "" -#: src/narrative_window.c:803 +#: src/narrative_window.c:802 #, c-format msgid "Narrative window is already open!\n" msgstr "" -#: src/narrative_window.c:853 data/menus.ui:134 +#: src/narrative_window.c:852 data/menus.ui:134 msgid "Start slideshow" msgstr "" -#: src/narrative_window.c:864 +#: src/narrative_window.c:863 msgid "Add slide" msgstr "" -#: src/narrative_window.c:874 +#: src/narrative_window.c:873 msgid "First slide" msgstr "" -#: src/narrative_window.c:881 +#: src/narrative_window.c:880 msgid "Previous slide" msgstr "" -#: src/narrative_window.c:888 +#: src/narrative_window.c:887 msgid "Next slide" msgstr "" -#: src/narrative_window.c:895 +#: src/narrative_window.c:894 msgid "Last slide" msgstr "" @@ -969,7 +969,7 @@ msgstr "" msgid "Slide" msgstr "" -#: data/menus.ui:124 +#: data/menus.ui:124 data/stylesheeteditor.ui:822 data/stylesheeteditor.ui:902 msgid "Slide title" msgstr "" @@ -1004,3 +1004,102 @@ msgstr "" #: data/menus.ui:192 msgid "_About" msgstr "" + +#: data/stylesheeteditor.ui:7 +msgid "Stylesheet editor" +msgstr "" + +#: data/stylesheeteditor.ui:77 +msgid "" +"This style will be used in the narrative editor and for slides unless " +"overridden" +msgstr "" + +#: data/stylesheeteditor.ui:95 data/stylesheeteditor.ui:471 +msgid "Text:" +msgstr "" + +#: data/stylesheeteditor.ui:146 data/stylesheeteditor.ui:522 +msgid "Background:" +msgstr "" + +#: data/stylesheeteditor.ui:160 data/stylesheeteditor.ui:535 +msgid "Flat colour" +msgstr "" + +#: data/stylesheeteditor.ui:161 data/stylesheeteditor.ui:536 +msgid "Horizontal gradient" +msgstr "" + +#: data/stylesheeteditor.ui:162 data/stylesheeteditor.ui:537 +msgid "Vertical gradient" +msgstr "" + +#: data/stylesheeteditor.ui:227 data/stylesheeteditor.ui:603 +msgid "Top:" +msgstr "" + +#: data/stylesheeteditor.ui:264 data/stylesheeteditor.ui:640 +msgid "Left:" +msgstr "" + +#: data/stylesheeteditor.ui:301 data/stylesheeteditor.ui:678 +msgid "Right:" +msgstr "" + +#: data/stylesheeteditor.ui:327 data/stylesheeteditor.ui:704 +msgid "Bottom:" +msgstr "" + +#: data/stylesheeteditor.ui:364 data/stylesheeteditor.ui:740 +msgid "Paragraph spacing" +msgstr "" + +#: data/stylesheeteditor.ui:402 data/stylesheeteditor.ui:778 +#: data/stylesheeteditor.ui:858 data/stylesheeteditor.ui:938 +msgid "Storycode" +msgstr "" + +#: data/stylesheeteditor.ui:419 +msgid "Default style" +msgstr "" + +#: data/stylesheeteditor.ui:439 +msgid "This style will be used in the narrative editor" +msgstr "" + +#: data/stylesheeteditor.ui:450 +msgid "Use default style" +msgstr "" + +#: data/stylesheeteditor.ui:798 +msgid "Narrative style" +msgstr "" + +#: data/stylesheeteditor.ui:821 data/stylesheeteditor.ui:901 +msgid "Presentation title" +msgstr "" + +#: data/stylesheeteditor.ui:878 +msgid "Style definitions" +msgstr "" + +#: data/stylesheeteditor.ui:958 +msgid "Templates" +msgstr "" + +#: data/stylesheeteditor.ui:984 +msgid "Slide width:" +msgstr "" + +#: data/stylesheeteditor.ui:1010 +msgid "Slide height:" +msgstr "" + +#: data/stylesheeteditor.ui:1036 +msgid "(arbitrary units)" +msgstr "" + +#: data/stylesheeteditor.ui:1064 +msgid "Properties" +msgstr "" diff --git a/src/colloquium.c b/src/colloquium.c index 3b1caa3..66e3dcb 100644 --- a/src/colloquium.c +++ b/src/colloquium.c @@ -338,6 +338,7 @@ static void colloquium_startup(GApplication *papp) G_N_ELEMENTS(app_entries), app); app->builder = gtk_builder_new_from_resource("/uk/me/bitwiz/Colloquium/menus.ui"); + gtk_builder_add_from_resource(app->builder, "/uk/me/bitwiz/Colloquium/windows.ui", NULL); gtk_application_set_menubar(GTK_APPLICATION(app), G_MENU_MODEL(gtk_builder_get_object(app->builder, "menubar"))); diff --git a/src/narrative_window.c b/src/narrative_window.c index 33609eb..1d254b1 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -40,6 +40,7 @@ #include "pr_clock.h" #include "print.h" #include "utils.h" +#include "stylesheet_editor.h" struct _narrative_window @@ -313,6 +314,18 @@ static gint load_ss_response_sig(GtkWidget *d, gint response, } +static void edit_ss_sig(GSimpleAction *action, GVariant *parameter, + gpointer vp) +{ + NarrativeWindow *nw = vp; + StylesheetEditor *se; + + se = stylesheet_editor_new(nw->p); + gtk_window_set_transient_for(GTK_WINDOW(se), GTK_WINDOW(nw->window)); + gtk_widget_show_all(GTK_WIDGET(se)); +} + + static void load_ss_sig(GSimpleAction *action, GVariant *parameter, gpointer vp) { @@ -741,6 +754,7 @@ GActionEntry nw_entries[] = { { "deleteslide", delete_slide_sig, NULL, NULL, NULL }, { "slide", add_slide_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 }, { "startslideshowhere", start_slideshow_here_sig, NULL, NULL, NULL }, { "startslideshownoslides", start_slideshow_noslides_sig, NULL, NULL, NULL }, diff --git a/src/stylesheet_editor.c b/src/stylesheet_editor.c new file mode 100644 index 0000000..85e053c --- /dev/null +++ b/src/stylesheet_editor.c @@ -0,0 +1,79 @@ +/* + * stylesheet_editor.c + * + * Copyright © 2013-2018 Thomas White + * + * 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 . + * + */ + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include "stylesheet_editor.h" +#include "presentation.h" + +G_DEFINE_TYPE_WITH_CODE(StylesheetEditor, stylesheet_editor, + GTK_TYPE_DIALOG, NULL) + +struct stylesheet_editor_private +{ + GtkDialog *default_style_ss; +}; + + +static void stylesheet_editor_init(StylesheetEditor *se) +{ + se->priv = G_TYPE_INSTANCE_GET_PRIVATE(se, COLLOQUIUM_TYPE_STYLESHEET_EDITOR, + struct stylesheet_editor_private); + gtk_widget_init_template(GTK_WIDGET(se)); +} + + +void stylesheet_editor_class_init(StylesheetEditorClass *klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + + gtk_widget_class_set_template_from_resource(widget_class, + "/uk/me/bitwiz/Colloquium/stylesheeteditor.ui"); + + gtk_widget_class_bind_template_child(widget_class, + struct stylesheet_editor_private, + default_style_ss); + + g_type_class_add_private(gobject_class, + sizeof(struct stylesheet_editor_private)); +} + + +StylesheetEditor *stylesheet_editor_new(struct presentation *p) +{ + StylesheetEditor *se; + + se = g_object_new(COLLOQUIUM_TYPE_STYLESHEET_EDITOR, NULL); + if ( se == NULL ) return NULL; + + return se; +} + diff --git a/src/stylesheet_editor.h b/src/stylesheet_editor.h new file mode 100644 index 0000000..ab2d65c --- /dev/null +++ b/src/stylesheet_editor.h @@ -0,0 +1,73 @@ +/* + * stylesheet_editor.h + * + * Copyright © 2013-2018 Thomas White + * + * 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 . + * + */ + +#ifndef STYLESHEET_EDITOR_H +#define STYLESHEET_EDITOR_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "presentation.h" + +#define COLLOQUIUM_TYPE_STYLESHEET_EDITOR (stylesheet_editor_get_type()) + +#define COLLOQUIUM_STYLESHEET_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + COLLOQUIUM_TYPE_STYLESHEET_EDITOR, \ + StylesheetEditor)) + +#define COLLOQUIUM_IS_STYLESHEET_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ + COLLOQUIUM_TYPE_STYLESHEET_EDITOR)) + +#define COLLOQUIUM_STYLESHEET_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((obj), \ + COLLOQUIUM_TYPE_STYLESHEET_EDITOR, \ + StylesheetEditorClass)) + +#define COLLOQUIUM_IS_STYLESHEET_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), \ + COLLOQUIUM_TYPE_STYLESHEET_EDITOR)) + +#define COLLOQUIUM_STYLESHEET_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), \ + COLLOQUIUM_TYPE_STYLESHEET_EDITOR, \ + StylesheetEditorClass)) + +struct stylesheet_editor_private; + +struct _stylesheeteditor +{ + GtkDialog parent_instance; + struct stylesheet_editor_private *priv; +}; + + +struct _stylesheeteditorclass +{ + GtkDialogClass parent_class; +}; + +typedef struct _stylesheeteditor StylesheetEditor; +typedef struct _stylesheeteditorclass StylesheetEditorClass; + +extern StylesheetEditor *stylesheet_editor_new(struct presentation *p); + +#endif /* STYLESHEET_EDITOR_H */ -- cgit v1.2.3