-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzebra_timeline.c
154 lines (120 loc) · 4.21 KB
/
zebra_timeline.c
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include <gtk/gtk.h>
#include "zebra_timeline.h"
#define ZEBRA_TIMELINE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), ZEBRA_TIMELINE_TYPE, ZebraTimelinePrivate))
typedef struct _ZebraTimelinePrivate ZebraTimelinePrivate;
struct _ZebraTimelinePrivate {
// Add private properties
};
enum {
FOO_SIGNAL,
// Add signals
LAST_SIGNAL
};
enum {
PROP_0,
PROP_BAR
// Add Properties
};
GType zebra_timeline_get_type(void){
static GType timeline_type = 0;
if (!timeline_type){
static const GTypeInfo timeline_info = {
sizeof(ZebraTimelineClass),
NULL,
NULL,
(GClassInitFunc) zebra_timeline_class_init,
NULL,
NULL,
sizeof(ZebraTimeline),
0,
(GInstanceInitFunc) zebra_timeline_init
};
timeline_type = g_type_register_static(GTK_TYPE_WIDGET, "ZebraTimeline", &timeline_info, 0);
}
return timeline_type;
}
static void zebra_timeline_class_init(ZebraTimelineClass *klass){
GObjectClass *gobject_class;
GtkWidgetClass *widget_class;
gobject_class = (GObjectClass*)klass;
widget_class = (GtkWidgetClass*)klass;
gobject_class->set_property = zebra_timeline_set_property;
gobject_class->get_property = zebra_timeline_get_property;
widget_class->realize = zebra_timeline_realize;
widget_class->expose = zebra_timeline_expose;
widget_class->size_request = zebra_timeline_size_request;
widget_class->size_allocate = zebra_timeline_size_allocate;
g_type_class_add_private(klass, sizeof(ZebraTimelinePrivate));
g_object_class_install_property(gobject_class, PROP_BAR,
g_param_spec_string("bar", "Bar message", "The bar message", "Foobar", G_PARAM_READWRITE)
);
}
static void zebra_timeline_init(ZebraTimeline *timeline){
//ZebraTimelinePrivate *priv = ZEBRA_TIMELINE_GET_PRIVATE(timeline);
// Init private data
}
static void zebra_timeline_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec){
ZebraTimeline *timeline = ZEBRA_TIMELINE(object);
switch (prop_id){
case PROP_BAR:
zebra_timeline_set_bar(timeline, (gchar*)g_value_get_string(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void zebra_timeline_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec){
ZebraTimeline *timeline = ZEBRA_TIMELINE(object);
// ZebraTimelinePrivate *priv = ZEBRA_TIMELINE_GET_PRIVATE(object);
switch (prop_id){
case PROP_BAR:
g_value_set_string(value, zebra_timeline_get_bar(timeline));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
GtkWidget *zebra_timeline_new(){
return GTK_WIDGET(g_object_new(zebra_timeline_get_type(), NULL));
}
static void zebra_timeline_realize(GtkWidget *widget){
ZebraTimeline *timeline;
GdkWindowAttr attributes;
gint attr_mask;
g_return_if_fail(widget != NULL);
g_return_if_fail(IS_ZEBRA_TIMELINE(widget));
gtk_widget_set_realized(widget, TRUE);
timeline = ZEBRA_TIMELINE(widget);
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
attributes.x = allocation.x;
attributes.y = allocation.y;
attributes.width = allocation.width;
attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.event_mask = gtk_widget_get_events(widget);
attributes.event_mask |= (GDK_EXPOSURE_MASK);
attributes.visual = gtk_widget_get_visual(widget);
//~ attributes.colormap = gtk_widget_get_colormap(widget);
attr_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
GtkWidget *parent = gtk_widget_get_parent(widget);
GdkWindow *gdk_window = gdk_window_new(gtk_widget_get_window(parent), &attributes, attr_mask);
gtk_widget_set_window(widget, gdk_window);
gdk_window_set_user_data(gdk_window, timeline);
//~ widget->style = gtk_style_attach(widget->style, widget->window);
//~ gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
gdk_window_show(gdk_window);
}
void zebra_timeline_set_bar(ZebraTimeline *timeline, gchar *bar){
}
gchar *zebra_timeline_get_bar(ZebraTimeline *timeline){
return NULL;
}
static void zebra_timeline_size_request(GtkWidget *widget, GtkRequisition *requisition){
}
static void zebra_timeline_size_allocate(GtkWidget *widget, GtkAllocation *allocation){
}
static gint zebra_timeline_expose(GtkWidget *widget, GdkEventExpose *event){
}