talkatu/talkatu

Move the demo to blueprint-compiler

18 months ago, Gary Kramlich
8c78e806f7c7
Parents 4b31fe51c0fb
Children e56cc1209e15
Move the demo to blueprint-compiler

Testing Done:
* Ran the demo checked just about everything.
* Used `gresource extract` to verify that the XML looked close enough to the old version.

Reviewed at https://reviews.imfreedom.org/r/1765/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demo/data/demo.blp Sun Sep 25 01:24:42 2022 -0500
@@ -0,0 +1,255 @@
+using Gtk 4.0;
+using Talkatu 0.0;
+
+Talkatu.Buffer buffer_plain {
+ changed => talkatu_demo_window_buffer_modified_cb();
+}
+
+Talkatu.WholeBuffer buffer_whole {
+ changed => talkatu_demo_window_buffer_modified_cb();
+}
+
+Talkatu.HtmlBuffer buffer_html {
+ changed => talkatu_demo_window_buffer_modified_cb();
+}
+
+Talkatu.MarkdownBuffer buffer_markdown {
+ changed => talkatu_demo_window_buffer_modified_cb();
+}
+
+menu author_menu {
+ section {
+ item {
+ label: _("Alice");
+ action: "win.author-name";
+ target: _("Alice");
+ }
+ item {
+ label: _("Bob");
+ action: "win.author-name";
+ target: _("Bob");
+ }
+ item {
+ label: _("Carol");
+ action: "win.author-name";
+ target: _("Carol");
+ }
+ item {
+ label: _("David");
+ action: "win.author-name";
+ target: _("David");
+ }
+ item {
+ label: _("Eve");
+ action: "win.author-name";
+ target: _("Eve");
+ }
+ item {
+ label: _("Mallory");
+ action: "win.author-name";
+ target: _("Mallory");
+ }
+ }
+}
+
+menu author_name_color_menu {
+ section {
+ item {
+ label: _("Black");
+ action: "win.author-name-color";
+ target: "black";
+ }
+ item {
+ label: _("White");
+ action: "win.author-name-color";
+ target: "white";
+ }
+ item {
+ label: _("Red");
+ action: "win.author-name-color";
+ target: "red";
+ }
+ item {
+ label: _("Green");
+ action: "win.author-name-color";
+ target: "green";
+ }
+ item {
+ label: _("Blue");
+ action: "win.author-name-color";
+ target: "blue";
+ }
+ item {
+ label: _("Yellow");
+ action: "win.author-name-color";
+ target: "yellow";
+ }
+ item {
+ label: _("Purple");
+ action: "win.author-name-color";
+ target: "purple";
+ }
+ }
+}
+
+template TalkatuDemoWindow : Gtk.ApplicationWindow {
+ Gtk.Paned {
+ shrink-end-child: false;
+ shrink-start-child: false;
+ orientation: vertical;
+ wide-handle: true;
+
+ Gtk.ScrolledWindow {
+ vadjustment: Talkatu.AutoScroller auto_scroller{};
+
+ Talkatu.History history {
+ name: "history";
+ }
+ }
+
+ Gtk.Box {
+ orientation: vertical;
+
+ Gtk.Box {
+ styles ["toolbar"]
+
+ can-focus: false;
+
+ Gtk.ToggleButton toggle_plain {
+ styles ["flat"]
+
+ can-focus: false;
+ tooltip-text: _("Use a TalkatuBuffer");
+ label: _("Plain");
+ use-underline: true;
+ icon-name: "text-x-generic";
+ active: true;
+
+ toggled => talkatu_demo_window_buffer_changed_cb();
+ }
+ Gtk.ToggleButton toggle_whole {
+ styles ["flat"]
+
+ can-focus: false;
+ tooltip-text: _("Use a TalkatuWholeBuffer");
+ label: _("Whole");
+ use-underline: true;
+ icon-name: "ascii";
+ group: toggle_plain;
+
+ toggled => talkatu_demo_window_buffer_changed_cb();
+ }
+ Gtk.ToggleButton toggle_html {
+ styles ["flat"]
+
+ can-focus: false;
+ tooltip-text: _("Use a TalkatuHTMLBuffer");
+ label: _("HTML");
+ use-underline: true;
+ icon-name: "text-html";
+ group: toggle_plain;
+
+ toggled => talkatu_demo_window_buffer_changed_cb();
+ }
+ Gtk.ToggleButton toggle_markdown {
+ styles ["flat"]
+
+ can-focus: false;
+ tooltip-text: _("Use a TalkatuMarkdownBuffer");
+ label: _("Markdown");
+ use-underline: true;
+ icon-name: "text-x-generic-template";
+ group: toggle_plain;
+
+ toggled => talkatu_demo_window_buffer_changed_cb();
+ }
+ Gtk.Separator {
+ orientation: vertical;
+ }
+ Gtk.Button {
+ can-focus: false;
+ tooltip-text: _("Insert HTML from a file");
+ label: _("Insert HTML");
+ use-underline: true;
+ icon-name: "text-html";
+
+ clicked => talkatu_demo_window_insert_html_cb();
+ }
+ Gtk.Button {
+ can-focus: false;
+ tooltip-text: _("Insert Markdown from a file");
+ label: _("Insert Markdown");
+ use-underline: true;
+ icon-name: "text-x-generic";
+
+ clicked => talkatu_demo_window_insert_markdown_cb();
+ }
+ Gtk.Separator {
+ orientation: vertical;
+ }
+ Gtk.MenuButton author_button {
+ can-focus: false;
+ icon-name: "system-users";
+ label: _("Author");
+ use-underline: true;
+ menu-model: author_menu;
+ }
+ Gtk.MenuButton author_name_color_button {
+ can-focus: false;
+ icon-name: "color-select-symbolic";
+ label: _("Color");
+ use-underline: true;
+ menu-model: author_name_color_menu;
+ }
+ Gtk.Separator {
+ orientation: vertical;
+ }
+ Gtk.ToggleButton toggle_toolbar {
+ styles ["flat"]
+
+ can-focus: false;
+ tooltip-text: _("Toggle toolbar visibility");
+ label: _("Toolbar");
+ use-underline: true;
+
+ active: bind editor.show-toolbar sync-create bidirectional;
+ }
+ Gtk.ToggleButton toggle_send_button {
+ styles ["flat"]
+
+ can-focus: false;
+ tooltip-text: _("Toggle send button visibility");
+ label: _("Send Button");
+ use-underline: true;
+ active: bind editor.show-send-button sync-create bidirectional;
+ }
+ Gtk.ToggleButton toggle_edited {
+ styles ["flat"]
+
+ can-focus: false;
+ tooltip-text: _("Toggle whether the message is edited");
+ label: _("Edited");
+ use-underline: true;
+ active: bind input.edited sync-create bidirectional;
+ }
+ }
+ Talkatu.Editor editor {
+ vexpand: true;
+ orientation: vertical;
+ show-send-button: false;
+
+ [internal-child input]
+ Talkatu.Input input {
+ author: _("Alice");
+ author-name-color: "black";
+ buffer: buffer_plain;
+ send-binding: return;
+
+ open-url => talkatu_demo_window_view_open_url_cb();
+ send-message => talkatu_demo_window_view_send_message_cb();
+ }
+ }
+ Talkatu.TypingLabel typing {}
+ }
+ }
+}
\ No newline at end of file
--- a/demo/data/demo.ui Sat Sep 17 23:37:00 2022 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,322 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.38.2
-
-Talkatu - GTK widgets for chat applications
-Copyright (C) 2017-2020 Gary Kramlich <grim@reaperworld.com>
-
-This program 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 2 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 library; if not, see <https://www.gnu.org/licenses/>.
-
--->
-<interface>
- <requires lib="Talkatu" version="0.0"/>
- <requires lib="gtk" version="4.0"/>
- <!-- interface-license-type gplv2 -->
- <!-- interface-name Talkatu -->
- <!-- interface-description GTK widgets for chat applications -->
- <!-- interface-copyright Gary Kramlich <grim@reaperworld.com> -->
- <object class="TalkatuAutoScroller" id="auto_scroller"/>
- <template class="TalkatuDemoWindow" parent="GtkApplicationWindow">
- <property name="child">
- <object class="GtkPaned">
- <property name="shrink-end-child">0</property>
- <property name="shrink-start-child">0</property>
- <property name="orientation">vertical</property>
- <property name="wide-handle">1</property>
- <child>
- <object class="GtkScrolledWindow">
- <property name="vadjustment">auto_scroller</property>
- <child>
- <object class="TalkatuHistory" id="history">
- <property name="name">history</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkBox">
- <style>
- <class name="toolbar"/>
- </style>
- <property name="can-focus">0</property>
- <child>
- <object class="GtkToggleButton" id="toggle_plain">
- <style>
- <class name="flat"/>
- </style>
- <property name="can-focus">0</property>
- <property name="tooltip-text" translatable="yes">Use a TalkatuBuffer</property>
- <property name="label" translatable="yes">Plain</property>
- <property name="use-underline">1</property>
- <property name="icon-name">text-x-generic</property>
- <property name="active">1</property>
- <signal name="toggled" handler="talkatu_demo_window_buffer_changed_cb" object="TalkatuDemoWindow" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkToggleButton" id="toggle_whole">
- <style>
- <class name="flat"/>
- </style>
- <property name="can-focus">0</property>
- <property name="tooltip-text" translatable="yes">Use a TalkatuWholeBuffer</property>
- <property name="label" translatable="yes">Whole</property>
- <property name="use-underline">1</property>
- <property name="icon-name">ascii</property>
- <property name="group">toggle_plain</property>
- <signal name="toggled" handler="talkatu_demo_window_buffer_changed_cb" object="TalkatuDemoWindow" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkToggleButton" id="toggle_html">
- <style>
- <class name="flat"/>
- </style>
- <property name="can-focus">0</property>
- <property name="tooltip-text" translatable="yes">Use a TalkatuHTMLBuffer</property>
- <property name="label" translatable="yes">HTML</property>
- <property name="use-underline">1</property>
- <property name="icon-name">text-html</property>
- <property name="group">toggle_plain</property>
- <signal name="toggled" handler="talkatu_demo_window_buffer_changed_cb" object="TalkatuDemoWindow" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkToggleButton" id="toggle_markdown">
- <style>
- <class name="flat"/>
- </style>
- <property name="can-focus">0</property>
- <property name="tooltip-text" translatable="yes">Use a TalkatuMarkdownBuffer</property>
- <property name="label" translatable="yes">Markdown</property>
- <property name="use-underline">1</property>
- <property name="icon-name">text-x-generic-template</property>
- <property name="group">toggle_plain</property>
- <signal name="toggled" handler="talkatu_demo_window_buffer_changed_cb" object="TalkatuDemoWindow" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkSeparator">
- <property name="orientation">vertical</property>
- <property name="can-focus">0</property>
- </object>
- </child>
- <child>
- <object class="GtkButton">
- <property name="can-focus">0</property>
- <property name="tooltip-text" translatable="yes">Insert HTML from a file</property>
- <property name="label" translatable="yes">Insert HTML</property>
- <property name="use-underline">1</property>
- <property name="icon-name">text-html</property>
- <signal name="clicked" handler="talkatu_demo_window_insert_html_cb" object="TalkatuDemoWindow" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkButton">
- <property name="can-focus">0</property>
- <property name="tooltip-text" translatable="yes">Insert Markdown from a file</property>
- <property name="label" translatable="yes">Insert Markdown</property>
- <property name="use-underline">1</property>
- <property name="icon-name">text-x-generic</property>
- <signal name="clicked" handler="talkatu_demo_window_insert_markdown_cb" object="TalkatuDemoWindow" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkSeparator">
- <property name="orientation">vertical</property>
- <property name="can-focus">0</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuButton" id="author_button">
- <property name="can-focus">0</property>
- <property name="icon-name">system-users</property>
- <property name="label" translatable="yes">Author</property>
- <property name="menu-model">author_menu</property>
- <property name="use-underline">1</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuButton" id="author_name_color_button">
- <property name="can-focus">0</property>
- <property name="icon-name">color-select-symbolic</property>
- <property name="label" translatable="yes">Color</property>
- <property name="menu-model">author_name_color_menu</property>
- <property name="use-underline">1</property>
- </object>
- </child>
- <child>
- <object class="GtkSeparator">
- <property name="orientation">vertical</property>
- <property name="can-focus">0</property>
- </object>
- </child>
- <child>
- <object class="GtkToggleButton" id="toggle_toolbar">
- <style>
- <class name="flat"/>
- </style>
- <property name="can-focus">0</property>
- <property name="tooltip-text" translatable="yes">Toggle toolbar visibility</property>
- <property name="label" translatable="yes">Toolbar</property>
- <property name="use-underline">1</property>
- </object>
- </child>
- <child>
- <object class="GtkToggleButton" id="toggle_send_button">
- <style>
- <class name="flat"/>
- </style>
- <property name="can-focus">0</property>
- <property name="tooltip-text" translatable="yes">Toggle send button visibility</property>
- <property name="label" translatable="yes">Send Button</property>
- <property name="use-underline">1</property>
- </object>
- </child>
- <child>
- <object class="GtkToggleButton" id="toggle_edited">
- <style>
- <class name="flat"/>
- </style>
- <property name="can-focus">0</property>
- <property name="tooltip-text" translatable="yes">Toggle whether the message is edited</property>
- <property name="label" translatable="yes">Edited</property>
- <property name="use-underline">1</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="TalkatuEditor" id="editor">
- <property name="vexpand">1</property>
- <property name="orientation">vertical</property>
- <property name="visible">True</property>
- <property name="vexpand-set">True</property>
- <child internal-child="toolbar">
- <object class="TalkatuToolbar">
- <property name="hexpand-set">True</property>
- <property name="vexpand-set">True</property>
- </object>
- </child>
- <child internal-child="input">
- <object class="TalkatuInput">
- <property name="buffer">buffer_plain</property>
- <property name="author">Alice</property>
- <property name="send-binding">1</property>
- <signal name="open-url" handler="talkatu_demo_window_view_open_url_cb" object="TalkatuDemoWindow" swapped="no"/>
- <signal name="send-message" handler="talkatu_demo_window_view_send_message_cb" object="TalkatuDemoWindow" swapped="no"/>
- </object>
- </child>
- <child internal-child="send_button">
- <object class="GtkButton">
- <property name="visible">0</property>
- <property name="can-focus">0</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="TalkatuTypingLabel" id="typing">
- <property name="visible">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </property>
- </template>
- <menu id="author_menu">
- <section>
- <item>
- <attribute name="label" translatable="yes">Alice</attribute>
- <attribute name="action">win.author-name</attribute>
- <attribute name="target" translatable="yes">Alice</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Bob</attribute>
- <attribute name="action">win.author-name</attribute>
- <attribute name="target" translatable="yes">Bob</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Carol</attribute>
- <attribute name="action">win.author-name</attribute>
- <attribute name="target" translatable="yes">Carol</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">David</attribute>
- <attribute name="action">win.author-name</attribute>
- <attribute name="target" translatable="yes">David</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Eve</attribute>
- <attribute name="action">win.author-name</attribute>
- <attribute name="target" translatable="yes">Eve</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Mallory</attribute>
- <attribute name="action">win.author-name</attribute>
- <attribute name="target" translatable="yes">Mallory</attribute>
- </item>
- </section>
- </menu>
- <menu id="author_name_color_menu">
- <section>
- <item>
- <attribute name="label" translatable="yes">Not set</attribute>
- <attribute name="action">win.author-name-color</attribute>
- <attribute name="target"></attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Red</attribute>
- <attribute name="action">win.author-name-color</attribute>
- <attribute name="target">red</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Green</attribute>
- <attribute name="action">win.author-name-color</attribute>
- <attribute name="target">green</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Blue</attribute>
- <attribute name="action">win.author-name-color</attribute>
- <attribute name="target">blue</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Yellow</attribute>
- <attribute name="action">win.author-name-color</attribute>
- <attribute name="target">yellow</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Purple</attribute>
- <attribute name="action">win.author-name-color</attribute>
- <attribute name="target">purple</attribute>
- </item>
- </section>
- </menu>
- <object class="TalkatuHtmlBuffer" id="buffer_html">
- <signal name="changed" handler="talkatu_demo_window_buffer_modified_cb" object="TalkatuDemoWindow" swapped="no"/>
- </object>
- <object class="TalkatuMarkdownBuffer" id="buffer_markdown">
- <signal name="changed" handler="talkatu_demo_window_buffer_modified_cb" object="TalkatuDemoWindow" swapped="no"/>
- </object>
- <object class="TalkatuBuffer" id="buffer_plain">
- <signal name="changed" handler="talkatu_demo_window_buffer_modified_cb" object="TalkatuDemoWindow" swapped="no"/>
- </object>
- <object class="TalkatuWholeBuffer" id="buffer_whole">
- <property name="style">whole</property>
- <signal name="changed" handler="talkatu_demo_window_buffer_modified_cb" object="TalkatuDemoWindow" swapped="no"/>
- </object>
-</interface>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demo/data/meson.build Sun Sep 25 01:24:42 2022 -0500
@@ -0,0 +1,26 @@
+bpfiles = [
+ 'demo.blp'
+]
+
+# We need to define our outputs from the custom_target, so we just create a new
+# list based off of the input with the extension changed.
+uifiles = []
+foreach bpfile : bpfiles
+ uifiles += bpfile.replace('.blp', '.ui')
+endforeach
+
+blueprints = custom_target('blueprints',
+ input: files(bpfiles),
+ output: uifiles,
+ command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTDIR@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
+ depends: [talkatu, talkatu_gir],
+ env: bpenv,
+)
+
+talkatudemo_resources = gnome.compile_resources(
+ 'talkatudemoresources',
+ 'talkatudemo.gresource.xml',
+ c_name: 'talkatudemo',
+ source_dir: '.',
+ dependencies: [blueprints],
+)
--- a/demo/meson.build Sat Sep 17 23:37:00 2022 -0500
+++ b/demo/meson.build Sun Sep 25 01:24:42 2022 -0500
@@ -7,15 +7,7 @@
'talkatudemowindow.h',
]
-###############################################################################
-# Resources
-###############################################################################
-talkatudemo_resources = gnome.compile_resources(
- 'talkatudemoresources',
- 'data/talkatudemo.gresource.xml',
- c_name: 'talkatudemo',
- source_dir: 'data'
-)
+subdir('data')
###############################################################################
# Demo program
--- a/demo/talkatudemowindow.c Sat Sep 17 23:37:00 2022 -0500
+++ b/demo/talkatudemowindow.c Sun Sep 25 01:24:42 2022 -0500
@@ -274,31 +274,13 @@
const GActionEntry entries[] = {
{ "author-name", talkatu_demo_window_author_changed, "s", "'Alice'" },
{ "author-name-color", talkatu_demo_window_author_name_color_changed,
- "s", "''" }
+ "s", "'black'" }
};
g_action_map_add_action_entries(G_ACTION_MAP(window), entries,
G_N_ELEMENTS(entries), window);
gtk_widget_init_template(GTK_WIDGET(window));
-
- g_object_bind_property(
- window->editor, "show-toolbar",
- window->toggle_toolbar, "active",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL
- );
-
- g_object_bind_property(
- window->editor, "show-send-button",
- window->toggle_send_button, "active",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL
- );
-
- g_object_bind_property(
- talkatu_editor_get_input(TALKATU_EDITOR(window->editor)), "edited",
- window->toggle_edited, "active",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL
- );
}
static void
--- a/meson.build Sat Sep 17 23:37:00 2022 -0500
+++ b/meson.build Sun Sep 25 01:24:42 2022 -0500
@@ -111,6 +111,8 @@
toplevel_inc = include_directories('.')
+bpenv = environment()
+
###############################################################################
# Subdirectories
###############################################################################
--- a/po/POTFILES Sat Sep 17 23:37:00 2022 -0500
+++ b/po/POTFILES Sun Sep 25 01:24:42 2022 -0500
@@ -1,4 +1,4 @@
-demo/data/demo.ui
+demo/data/demo.blp
demo/talkatudemo.c
demo/talkatudemowindow.c
talkatu/data/attachmentdialog.ui
@@ -8,7 +8,6 @@
talkatu/data/history.ui
talkatu/data/input.ui
talkatu/data/linkdialog.ui
-talkatu/data/scrolledwindow.ui
talkatu/data/toolbar.ui
talkatu/data/typinglabel.ui
talkatu/data/view.ui
--- a/po/meson.build Sat Sep 17 23:37:00 2022 -0500
+++ b/po/meson.build Sun Sep 25 01:24:42 2022 -0500
@@ -1,3 +1,3 @@
if get_option('nls')
- i18n.gettext(GETTEXT_PACKAGE)
+ i18n.gettext(GETTEXT_PACKAGE, preset: 'glib')
endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/subprojects/blueprint-compiler.wrap Sun Sep 25 01:24:42 2022 -0500
@@ -0,0 +1,8 @@
+[wrap-git]
+directory = blueprint-compiler
+url = https://gitlab.gnome.org/jwestman/blueprint-compiler.git
+revision = main
+depth = 1
+
+[provide]
+program_names = blueprint-compiler
\ No newline at end of file
--- a/talkatu/meson.build Sat Sep 17 23:37:00 2022 -0500
+++ b/talkatu/meson.build Sun Sep 25 01:24:42 2022 -0500
@@ -206,6 +206,8 @@
symbol_prefix : 'talkatu',
)
TALKATU_GENERATED_TARGETS += talkatu_gir
+
+ bpenv.append('GI_TYPELIB_PATH', meson.current_build_dir())
endif
###############################################################################