aboutsummaryrefslogtreecommitdiff
path: root/lib/gtk-experiment-widgets/gtk-experiment-transcript-private.h
blob: 6fe821824510d45ddfcd5975027b8e4800d00282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
 * @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 */
	GSList		*alignment_group;	/**< GtkRadioMenuItem group (owned by GTK) */
};

#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