summaryrefslogtreecommitdiffstats
path: root/src/qt_rc_style.c
blob: ea1ecf9ba4bc435bfbb0651db943b796995eb2b9 (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
92
93
94
95
96
97
98
99
100
101
102
103
#include "qt_rc_style.h"
#include "qt_style.h"
#include "qt_qt_wrapper.h"



static void      qtengine_rc_style_init         (QtEngineRcStyle      *style);
static void      qtengine_rc_style_class_init   (QtEngineRcStyleClass *klass);
static guint     qtengine_rc_style_parse        (GtkRcStyle          *rc_style,
					       GtkSettings          *settings,
					       GScanner             *scanner);
static void      qtengine_rc_style_merge       (GtkRcStyle           *dest,
					       GtkRcStyle           *src);

static GtkStyle *qtengine_rc_style_create_style (GtkRcStyle          *rc_style);

static GtkRcStyleClass *parent_class;

GType qtengine_type_rc_style = 0;


void qtengine_rc_style_register_type (GTypeModule *module)
{
	static const GTypeInfo object_info =
	{
		sizeof (QtEngineRcStyleClass),
		(GBaseInitFunc) NULL,
		(GBaseFinalizeFunc) NULL,
		(GClassInitFunc) qtengine_rc_style_class_init,
		NULL,           /* class_finalize */
		NULL,           /* class_data */
		sizeof (QtEngineRcStyle),
		0,              /* n_preallocs */
		(GInstanceInitFunc) qtengine_rc_style_init,
	};
  
	qtengine_type_rc_style = g_type_module_register_type (module, GTK_TYPE_RC_STYLE, "QtEngineRcStyle", &object_info, 0);
}

static void qtengine_rc_style_init (QtEngineRcStyle *style)
{
}

static void qtengine_rc_style_class_init (QtEngineRcStyleClass *klass)
{
	GtkRcStyleClass *rc_style_class = GTK_RC_STYLE_CLASS (klass);
	
	parent_class = g_type_class_peek_parent (klass);
	
	rc_style_class->parse = qtengine_rc_style_parse;
	rc_style_class->merge = qtengine_rc_style_merge;
	rc_style_class->create_style = qtengine_rc_style_create_style;
}




static guint
qtengine_rc_style_parse (GtkRcStyle *rc_style, GtkSettings *settings, GScanner *scanner)
{
	static GQuark       scope_id = 0;
	guint               old_scope;
	guint               token;
	
	/* Sets Rc properties from TQt settings */
#ifdef FORCE_RELOAD_THEMES_ON_STARTUP
	setRcProperties(rc_style, 1);
#else
	setRcProperties(rc_style, 0);
#endif
	
	/* The rest of this keeps GTK happy - therefore I don't care what it does */
	if (!scope_id)
		scope_id = g_quark_from_string("theme_engine");
	
	old_scope = g_scanner_set_scope(scanner, scope_id);
	
	token = g_scanner_get_next_token(scanner);
	while (token != G_TOKEN_RIGHT_CURLY)
	{
		token = g_scanner_get_next_token(scanner);
	}
	
	g_scanner_set_scope(scanner, old_scope);
	
	return G_TOKEN_NONE;
}

static void
qtengine_rc_style_merge (GtkRcStyle * dest,
			GtkRcStyle * src)
{
	parent_class->merge(dest, src);
}

/* Create an empty style suitable to this RC style
 */
static GtkStyle *
qtengine_rc_style_create_style (GtkRcStyle *rc_style)
{
	void *ptr = GTK_STYLE (g_object_new (TQTENGINE_TYPE_STYLE, NULL));
	return (GtkStyle *)ptr;
}