diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-05-20 17:08:31 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-05-30 15:56:16 +0200 |
commit | a766006297e8fa8b8168b7a887098d5176a87b20 (patch) | |
tree | 6aee522990538c60aaff56cbfc66fedb89d163ae /lib/gtk-experiment-widgets/gtk-experiment-transcript-private.h | |
parent | b2229a97882e31e0c89061184731082cfd13ec03 (diff) | |
download | experiment-player-a766006297e8fa8b8168b7a887098d5176a87b20.tar.gz |
implemented "format" file and expression parsing as well as application to the transcript
* "formats" are regular expressions encapsulated in Pango markup that allow the description of powerful highlighting rules
* highlight as you type via entry boxes
* loading from files implemented and tested but cannot yet be done via the UI
* transcript widget is built as libtool convenience library
* some renamings were necessary
* install transcript widget header
Diffstat (limited to 'lib/gtk-experiment-widgets/gtk-experiment-transcript-private.h')
-rw-r--r-- | lib/gtk-experiment-widgets/gtk-experiment-transcript-private.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/lib/gtk-experiment-widgets/gtk-experiment-transcript-private.h b/lib/gtk-experiment-widgets/gtk-experiment-transcript-private.h new file mode 100644 index 0000000..8dc47c1 --- /dev/null +++ b/lib/gtk-experiment-widgets/gtk-experiment-transcript-private.h @@ -0,0 +1,90 @@ +/** + * @file + * Private header for the \e GtkExperimentTranscript widget + */ + +#ifndef __GTK_EXPERIMENT_TRANSCRIPT_PRIVATE_H +#define __GTK_EXPERIMENT_TRANSCRIPT_PRIVATE_H + +#include "gtk-experiment-transcript.h" + +/** @private */ +#define GTK_EXPERIMENT_TRANSCRIPT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GTK_TYPE_EXPERIMENT_TRANSCRIPT, GtkExperimentTranscriptPrivate)) + +/** @private */ +typedef struct _GtkExperimentTranscriptFormat { + GRegex *regexp; + PangoAttrList *attribs; +} GtkExperimentTranscriptFormat; + +/** + * @private + * Private instance attribute structure. + * You can access these attributes using \c klass->priv->attribute. + */ +struct _GtkExperimentTranscriptPrivate { + GtkObject *time_adjustment; + gulong time_adj_on_value_changed_id; + + GdkPixmap *layer_text; + PangoLayout *layer_text_layout; + + GList *contribs; + GSList *formats; + GtkExperimentTranscriptFormat interactive_format; + + GtkWidget *menu; /**< Drop-down menu, doesn't have to be unreferenced manually */ +}; + +#define DEFAULT_WIDTH 100 +#define DEFAULT_HEIGHT 200 + +#define LAYER_TEXT_INVISIBLE 100 + +/** @todo scale should be configurable */ +#define PX_PER_SECOND 15 +#define TIME_TO_PX(TIME) ((TIME)/(1000/PX_PER_SECOND)) +#define PX_TO_TIME(PX) (((PX)*1000)/PX_PER_SECOND) + +/** + * @private + * Unreference object given by variable, but only once. + * Use it in \ref gtk_experiment_transcript_dispose to unreference object + * references in public or private instance attributes. + * + * @sa gtk_experiment_transcript_dispose + * + * @param VAR Variable to unreference + */ +#define GOBJECT_UNREF_SAFE(VAR) do { \ + if ((VAR) != NULL) { \ + g_object_unref(VAR); \ + VAR = NULL; \ + } \ +} while (0) + +/** @private */ +void gtk_experiment_transcript_text_layer_redraw(GtkExperimentTranscript *trans); + +/** @private */ +void gtk_experiment_transcript_apply_format(GtkExperimentTranscriptFormat *fmt, + const gchar *text, + PangoAttrList *attrib_list); + +/** @private */ +static inline void +gtk_experiment_transcript_free_format(GtkExperimentTranscriptFormat *format) +{ + if (format->regexp != NULL) + g_regex_unref(format->regexp); + if (format->attribs != NULL) + pango_attr_list_unref(format->attribs); +} + +/** @private */ +void gtk_experiment_transcript_free_formats(GSList *formats); + + + +#endif |