aboutsummaryrefslogtreecommitdiff
path: root/lib/gtk-experiment-widgets
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gtk-experiment-widgets')
-rw-r--r--lib/gtk-experiment-widgets/gtk-experiment-transcript-formats.c67
-rw-r--r--lib/gtk-experiment-widgets/gtk-experiment-transcript.c11
-rw-r--r--lib/gtk-experiment-widgets/gtk-experiment-transcript.h8
3 files changed, 47 insertions, 39 deletions
diff --git a/lib/gtk-experiment-widgets/gtk-experiment-transcript-formats.c b/lib/gtk-experiment-widgets/gtk-experiment-transcript-formats.c
index 3898e30..d5b2f5e 100644
--- a/lib/gtk-experiment-widgets/gtk-experiment-transcript-formats.c
+++ b/lib/gtk-experiment-widgets/gtk-experiment-transcript-formats.c
@@ -203,47 +203,12 @@ gtk_experiment_transcript_set_interactive_format(GtkExperimentTranscript *trans,
const gchar *format_str,
gboolean with_markup)
{
- static PangoAttrList *default_attribs = NULL;
-
GtkExperimentTranscriptFormat *fmt = &trans->priv->interactive_format;
- gchar *pattern;
- gboolean res = TRUE;
- if (default_attribs == NULL) {
- PangoAttribute *attrib;
- PangoFontDescription *font;
- PangoColor color;
-
- default_attribs = pango_attr_list_new();
+ gchar *pattern;
+ PangoAttribute *attrib;
-#ifdef DEFAULT_INTERACTIVE_FORMAT_FONT
- font = pango_font_description_from_string(DEFAULT_INTERACTIVE_FORMAT_FONT);
- if (font != NULL) {
- attrib = pango_attr_font_desc_new(font);
- attrib->end_index = 1;
- pango_attr_list_insert(default_attribs, attrib);
- pango_font_description_free(font);
- }
-#endif
-#ifdef DEFAULT_INTERACTIVE_FORMAT_FGCOLOR
- if (pango_color_parse(&color, DEFAULT_INTERACTIVE_FORMAT_FGCOLOR)) {
- attrib = pango_attr_foreground_new(color.red,
- color.green,
- color.blue);
- attrib->end_index = 1;
- pango_attr_list_insert(default_attribs, attrib);
- }
-#endif
-#ifdef DEFAULT_INTERACTIVE_FORMAT_BGCOLOR
- if (pango_color_parse(&color, DEFAULT_INTERACTIVE_FORMAT_BGCOLOR)) {
- attrib = pango_attr_background_new(color.red,
- color.green,
- color.blue);
- attrib->end_index = 1;
- pango_attr_list_insert(default_attribs, attrib);
- }
-#endif
- }
+ gboolean res = TRUE;
gtk_experiment_transcript_free_format(fmt);
fmt->regexp = NULL;
@@ -260,10 +225,34 @@ gtk_experiment_transcript_set_interactive_format(GtkExperimentTranscript *trans,
}
/* else if (!with_markup) */
- fmt->attribs = pango_attr_list_copy(default_attribs);
+ fmt->attribs = pango_attr_list_new();
if (fmt->attribs == NULL)
goto redraw;
+ if (trans->interactive_format.default_font != NULL) {
+ attrib = pango_attr_font_desc_new(trans->interactive_format.default_font);
+ attrib->end_index = 1;
+ pango_attr_list_insert(fmt->attribs, attrib);
+ }
+ if (trans->interactive_format.default_text_color != NULL) {
+ GdkColor *color = trans->interactive_format.default_text_color;
+
+ attrib = pango_attr_foreground_new(color->red,
+ color->green,
+ color->blue);
+ attrib->end_index = 1;
+ pango_attr_list_insert(fmt->attribs, attrib);
+ }
+ if (trans->interactive_format.default_bg_color != NULL) {
+ GdkColor *color = trans->interactive_format.default_bg_color;
+
+ attrib = pango_attr_background_new(color->red,
+ color->green,
+ color->blue);
+ attrib->end_index = 1;
+ pango_attr_list_insert(fmt->attribs, attrib);
+ }
+
pattern = g_strconcat("(", format_str, ")", NULL);
fmt->regexp = g_regex_new(pattern, FORMAT_REGEX_COMPILE_FLAGS, 0, NULL);
g_free(pattern);
diff --git a/lib/gtk-experiment-widgets/gtk-experiment-transcript.c b/lib/gtk-experiment-widgets/gtk-experiment-transcript.c
index e5a9384..0c2b373 100644
--- a/lib/gtk-experiment-widgets/gtk-experiment-transcript.c
+++ b/lib/gtk-experiment-widgets/gtk-experiment-transcript.c
@@ -13,6 +13,8 @@
#include <glib.h>
#include <glib/gprintf.h>
+#include <gdk/gdk.h>
+
#include <gtk/gtk.h>
#include <experiment-reader.h>
@@ -85,6 +87,10 @@ gtk_experiment_transcript_init(GtkExperimentTranscript *klass)
klass->speaker = NULL;
klass->reverse = FALSE;
+ klass->interactive_format.default_font = NULL;
+ klass->interactive_format.default_text_color = NULL;
+ klass->interactive_format.default_bg_color = NULL;
+
klass->priv->time_adjustment = gtk_adjustment_new(0., 0., 0.,
0., 0., 0.);
g_object_ref_sink(klass->priv->time_adjustment);
@@ -197,6 +203,11 @@ gtk_experiment_transcript_finalize(GObject *gobject)
GtkExperimentTranscript *trans = GTK_EXPERIMENT_TRANSCRIPT(gobject);
g_free(trans->speaker);
+
+ pango_font_description_free(trans->interactive_format.default_font);
+ gdk_color_free(trans->interactive_format.default_text_color);
+ gdk_color_free(trans->interactive_format.default_bg_color);
+
experiment_reader_free_contributions(trans->priv->contribs);
gtk_experiment_transcript_free_formats(trans->priv->formats);
gtk_experiment_transcript_free_format(&trans->priv->interactive_format);
diff --git a/lib/gtk-experiment-widgets/gtk-experiment-transcript.h b/lib/gtk-experiment-widgets/gtk-experiment-transcript.h
index fa4b7ab..9d65863 100644
--- a/lib/gtk-experiment-widgets/gtk-experiment-transcript.h
+++ b/lib/gtk-experiment-widgets/gtk-experiment-transcript.h
@@ -8,6 +8,8 @@
#define __GTK_EXPERIMENT_TRANSCRIPT_H
#include <glib-object.h>
+#include <gdk/gdk.h>
+
#include <gtk/gtk.h>
#include <experiment-reader.h>
@@ -45,6 +47,12 @@ typedef struct _GtkExperimentTranscript {
gchar *speaker; /**< Name of speaker whose contributions are displayed (\b read-only) */
gboolean reverse; /**< Reverse mode (\b read-write) */
+ struct _GtkExperimentTranscriptInteractiveFormat {
+ PangoFontDescription *default_font; /**< Default interactive format font */
+ GdkColor *default_text_color; /**< Default interactive format text color */
+ GdkColor *default_bg_color; /**< Default interactive format background color */
+ } interactive_format;
+
GtkExperimentTranscriptPrivate *priv; /**< @private Pointer to \b private instance attributes */
} GtkExperimentTranscript;