--- a/demo/data/demo.ui Wed Sep 12 00:30:05 2018 -0500
+++ b/demo/data/demo.ui Thu Sep 13 12:24:30 2018 -0500
@@ -199,7 +199,7 @@
- <object class="TalkatuHtmlBuffer" id="buffer_whole">
+ <object class="TalkatuWholeBuffer" id="buffer_whole"> <property name="tag_table">table_plain</property>
<property name="style">whole</property>
--- a/talkatu/meson.build Wed Sep 12 00:30:05 2018 -0500
+++ b/talkatu/meson.build Thu Sep 13 12:24:30 2018 -0500
@@ -23,6 +23,7 @@
+ 'talkatuwholebuffer.h', @@ -45,6 +46,7 @@
+ 'talkatuwholebuffer.c', TALKATU_PUBLIC_BUILT_HEADERS = [
--- a/talkatu/talkatu.xml Wed Sep 12 00:30:05 2018 -0500
+++ b/talkatu/talkatu.xml Thu Sep 13 12:24:30 2018 -0500
@@ -35,6 +35,12 @@
+ <glade-widget-class name="TalkatuWholeBuffer" generic-name="buffer" title="Whole Buffer" toplevel="True"> + <property translatable="True" multiline="True" id="text"/> <glade-widget-class name="TalkatuHistoryBuffer" generic-name="buffer" title="History Buffer" toplevel="True">
<property translatable="True" multiline="True" id="text"/>
@@ -53,6 +59,7 @@
<glade-widget-class-ref name="TalkatuToolDrawer"/>
<glade-widget-class-ref name="TalkatuToolbar"/>
<glade-widget-class-ref name="TalkatuView"/>
+ <glade-widget-class-ref name="TalkatuWholeBuffer"/> <glade-widget-class-ref name="TalkatuTagTable"/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/talkatu/talkatuwholebuffer.c Thu Sep 13 12:24:30 2018 -0500
@@ -0,0 +1,109 @@
+ * Copyright (C) 2017-2018 Gary Kramlich <grim@reaperworld.com> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library 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 + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. +#include "talkatu/talkatuaction.h" +#include "talkatu/talkatuwholebuffer.h" + * SECTION:talkatuwhole_buffer + * @Short_description: A whole format text buffer + * TalkatuWholeBuffer is a #GtkTextBuffer who's formatting applied to the + * entire buffer and not on a character by character basis. +G_DEFINE_TYPE(TalkatuWholeBuffer, talkatu_whole_buffer, TALKATU_TYPE_BUFFER) +/****************************************************************************** + *****************************************************************************/ +static GSimpleActionGroup * +talkatu_whole_buffer_create_action_group(TalkatuBuffer *buffer) { + GSimpleActionGroup *action_group = g_simple_action_group_new(); + /* order of operation sucks, we need the buffer for the callbacks, but we + * need the group to create the buffer. + talkatu_action_add_bold(G_ACTION_MAP(action_group), GTK_TEXT_BUFFER(buffer)); + talkatu_action_add_italic(G_ACTION_MAP(action_group), GTK_TEXT_BUFFER(buffer)); + talkatu_action_add_underline(G_ACTION_MAP(action_group), GTK_TEXT_BUFFER(buffer)); + talkatu_action_add_strikethrough(G_ACTION_MAP(action_group), GTK_TEXT_BUFFER(buffer)); + talkatu_action_add_grow(G_ACTION_MAP(action_group), GTK_TEXT_BUFFER(buffer)); + talkatu_action_add_shrink(G_ACTION_MAP(action_group), GTK_TEXT_BUFFER(buffer)); + talkatu_action_add_reset(G_ACTION_MAP(action_group), GTK_TEXT_BUFFER(buffer)); + talkatu_action_add_link(G_ACTION_MAP(action_group), GTK_TEXT_BUFFER(buffer)); +/****************************************************************************** + *****************************************************************************/ +talkatu_whole_buffer_constructor(GType type, + GObjectConstructParam *params) + GObjectConstructParam *param; + for(i = 0, param = params; i < n_params; i++, param++) { + const gchar *name = g_param_spec_get_name(param->pspec); + if(g_ascii_strcasecmp("style", name) == 0) { + g_value_set_enum(param->value, TALKATU_BUFFER_STYLE_WHOLE); + return G_OBJECT_CLASS(talkatu_whole_buffer_parent_class)->constructor(type, n_params, params); +talkatu_whole_buffer_init(TalkatuWholeBuffer *whole_buffer) { +talkatu_whole_buffer_class_init(TalkatuWholeBufferClass *klass) { + GObjectClass *obj_class = G_OBJECT_CLASS(klass); + TalkatuBufferClass *buffer_class = TALKATU_BUFFER_CLASS(klass); + obj_class->constructor = talkatu_whole_buffer_constructor; + buffer_class->create_action_group = talkatu_whole_buffer_create_action_group; +/****************************************************************************** + *****************************************************************************/ + * talkatu_whole_buffer_new: + * Creates a new #TalkatuWholeBuffer that applies formatting across the whole + * text buffer instead of just a subset. + * Returns: (transfer full): The new #TalkatuWholeBuffer instance. +GtkTextBuffer *talkatu_whole_buffer_new(void) { + return GTK_TEXT_BUFFER(g_object_new( + TALKATU_TYPE_WHOLE_BUFFER, + "style", TALKATU_BUFFER_STYLE_WHOLE, --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/talkatu/talkatuwholebuffer.h Thu Sep 13 12:24:30 2018 -0500
@@ -0,0 +1,73 @@
+ * Copyright (C) 2017-2018 Gary Kramlich <grim@reaperworld.com> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library 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 + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. +#ifndef __GI_SCANNER__ /* hide this bit from g-ir-scanner */ +#if !defined(TALKATU_GLOBAL_HEADER_INSIDE) && !defined(TALKATU_COMPILATION) +#error "only <talkatu.h> may be included directly" +#endif /* __GI_SCANNER__ */ +#ifndef TALKATU_WHOLE_BUFFER_H +#define TALKATU_WHOLE_BUFFER_H +#define TALKATU_TYPE_WHOLE_BUFFER (talkatu_whole_buffer_get_type()) +#define TALKATU_WHOLE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TALKATU_TYPE_WHOLE_BUFFER, TalkatuWholeBuffer)) +#define TALKATU_WHOLE_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), TALKATU_TYPE_WHOLE_BUFFER, TalkatuWholeBufferClass)) +#define TALKATU_IS_WHOLE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TALKATU_TYPE_WHOLE_BUFFER)) +#define TALKATU_IS_WHOLE_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TALKATU_TYPE_WHOLE_BUFFER)) +#define TALKATU_WHOLE_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TALKATU_TYPE_WHOLE_BUFFER, TalkatuWholeBufferClass)) +typedef struct _TalkatuWholeBuffer TalkatuWholeBuffer; +typedef struct _TalkatuWholeBufferClass TalkatuWholeBufferClass; +#include <glib-object.h> +#include <talkatu/talkatubuffer.h> +struct _TalkatuWholeBuffer { + void (*_talkatu_reserved1)(void); + void (*_talkatu_reserved2)(void); + void (*_talkatu_reserved3)(void); + void (*_talkatu_reserved4)(void); +struct _TalkatuWholeBufferClass { + TalkatuBufferClass parent; + void (*_talkatu_reserved1)(void); + void (*_talkatu_reserved2)(void); + void (*_talkatu_reserved3)(void); + void (*_talkatu_reserved4)(void); +GType talkatu_whole_buffer_get_type(void); +GtkTextBuffer *talkatu_whole_buffer_new(void); +#endif /* TALKATU_WHOLE_BUFFER_H */