1 | |
2 | #include<gtk/gtk.h> |
3 | |
4 | static const char *css = |
5 | ".one {" |
6 | " all: unset;" |
7 | " min-width: 100px;" |
8 | " min-height:100px;" |
9 | " border-left: 50px solid #0f0;" |
10 | " border-top: 10px solid red;" |
11 | " border-bottom: 50px solid teal;" |
12 | " border-right: 100px solid pink;" |
13 | " border-radius: 100px;" |
14 | "}" |
15 | ".two {" |
16 | " all: unset;" |
17 | " min-width: 100px;" |
18 | " min-height:100px;" |
19 | " border-left: 50px solid #0f0;" |
20 | " border-top: 10px solid red;" |
21 | " border-bottom: 50px solid teal;" |
22 | " border-right: 100px solid pink;" |
23 | " border-radius: 50%;" |
24 | "}" |
25 | ".three {" |
26 | " all: unset;" |
27 | " min-width: 100px;" |
28 | " min-height:100px;" |
29 | " border-left: 50px solid #0f0;" |
30 | " border-top: 10px solid red;" |
31 | " border-bottom: 50px solid teal;" |
32 | " border-right: 100px solid pink;" |
33 | " border-radius: 0px;" |
34 | "}" |
35 | ".four {" |
36 | " all: unset;" |
37 | " min-width: 100px;" |
38 | " min-height:100px;" |
39 | " border: 10px solid black;" |
40 | " border-radius: 999px;" |
41 | "}" |
42 | ".five {" |
43 | " all: unset;" |
44 | " min-width: 100px;" |
45 | " min-height:100px;" |
46 | " border: 30px solid black;" |
47 | " border-radius: 0px;" |
48 | "}" |
49 | ".b1 {" |
50 | " all: unset;" |
51 | " min-width: 100px;" |
52 | " min-height:100px;" |
53 | " border-top: 30px solid black;" |
54 | " border-radius: 0px;" |
55 | "}" |
56 | ".b2 {" |
57 | " all: unset;" |
58 | " min-width: 100px;" |
59 | " min-height:100px;" |
60 | " border-bottom: 30px solid black;" |
61 | " border-radius: 0px;" |
62 | "}" |
63 | ".b3 {" |
64 | " all: unset;" |
65 | " min-width: 100px;" |
66 | " min-height:100px;" |
67 | " border-right: 30px solid blue;" |
68 | " border-radius: 40px;" |
69 | "}" |
70 | ".b4 {" |
71 | " all: unset;" |
72 | " min-width: 100px;" |
73 | " min-height:100px;" |
74 | " border-bottom: 30px solid blue;" |
75 | " border-radius: 40px;" |
76 | "}" |
77 | ; |
78 | |
79 | static void |
80 | quit_cb (GtkWidget *widget, |
81 | gpointer data) |
82 | { |
83 | gboolean *done = data; |
84 | |
85 | *done = TRUE; |
86 | |
87 | g_main_context_wakeup (NULL); |
88 | } |
89 | |
90 | int |
91 | main (int argc, char **argv) |
92 | { |
93 | GtkWidget *window; |
94 | GtkWidget *box; |
95 | GtkWidget *top; |
96 | GtkWidget *bottom; |
97 | GtkWidget *w; |
98 | GtkCssProvider *provider; |
99 | gboolean done = FALSE; |
100 | |
101 | gtk_init (); |
102 | |
103 | provider = gtk_css_provider_new (); |
104 | gtk_css_provider_load_from_data (css_provider: provider, data: css, length: -1); |
105 | gtk_style_context_add_provider_for_display (display: gdk_display_get_default (), |
106 | GTK_STYLE_PROVIDER (provider), |
107 | GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); |
108 | |
109 | window = gtk_window_new (); |
110 | box = gtk_box_new (orientation: GTK_ORIENTATION_VERTICAL, spacing: 40); |
111 | top = gtk_box_new (orientation: GTK_ORIENTATION_HORIZONTAL, spacing: 40); |
112 | bottom = gtk_box_new (orientation: GTK_ORIENTATION_HORIZONTAL, spacing: 40); |
113 | gtk_widget_set_margin_start (widget: box, margin: 40); |
114 | gtk_widget_set_margin_end (widget: box, margin: 40); |
115 | gtk_widget_set_margin_top (widget: box, margin: 40); |
116 | gtk_widget_set_margin_bottom (widget: box, margin: 40); |
117 | |
118 | w = gtk_button_new (); |
119 | gtk_widget_set_valign (widget: w, align: GTK_ALIGN_CENTER); |
120 | gtk_widget_add_css_class (widget: w, css_class: "one" ); |
121 | gtk_box_append (GTK_BOX (top), child: w); |
122 | |
123 | w = gtk_button_new (); |
124 | gtk_widget_set_valign (widget: w, align: GTK_ALIGN_CENTER); |
125 | gtk_widget_add_css_class (widget: w, css_class: "two" ); |
126 | gtk_box_append (GTK_BOX (top), child: w); |
127 | |
128 | w = gtk_button_new (); |
129 | gtk_widget_set_valign (widget: w, align: GTK_ALIGN_CENTER); |
130 | gtk_widget_add_css_class (widget: w, css_class: "three" ); |
131 | gtk_box_append (GTK_BOX (top), child: w); |
132 | |
133 | w = gtk_button_new (); |
134 | gtk_widget_set_valign (widget: w, align: GTK_ALIGN_CENTER); |
135 | gtk_widget_add_css_class (widget: w, css_class: "four" ); |
136 | gtk_box_append (GTK_BOX (top), child: w); |
137 | |
138 | w = gtk_button_new (); |
139 | gtk_widget_set_valign (widget: w, align: GTK_ALIGN_CENTER); |
140 | gtk_widget_add_css_class (widget: w, css_class: "five" ); |
141 | gtk_box_append (GTK_BOX (top), child: w); |
142 | |
143 | |
144 | /* Bottom */ |
145 | w = gtk_button_new (); |
146 | gtk_widget_set_valign (widget: w, align: GTK_ALIGN_CENTER); |
147 | gtk_widget_add_css_class (widget: w, css_class: "b1" ); |
148 | gtk_box_append (GTK_BOX (bottom), child: w); |
149 | |
150 | w = gtk_button_new (); |
151 | gtk_widget_set_valign (widget: w, align: GTK_ALIGN_CENTER); |
152 | gtk_widget_add_css_class (widget: w, css_class: "b2" ); |
153 | gtk_box_append (GTK_BOX (bottom), child: w); |
154 | |
155 | w = gtk_button_new (); |
156 | gtk_widget_set_valign (widget: w, align: GTK_ALIGN_CENTER); |
157 | gtk_widget_add_css_class (widget: w, css_class: "b3" ); |
158 | gtk_box_append (GTK_BOX (bottom), child: w); |
159 | |
160 | w = gtk_button_new (); |
161 | gtk_widget_set_valign (widget: w, align: GTK_ALIGN_CENTER); |
162 | gtk_widget_add_css_class (widget: w, css_class: "b4" ); |
163 | gtk_box_append (GTK_BOX (bottom), child: w); |
164 | |
165 | gtk_box_append (GTK_BOX (box), child: top); |
166 | gtk_box_append (GTK_BOX (box), child: bottom); |
167 | gtk_window_set_child (GTK_WINDOW (window), child: box); |
168 | g_signal_connect (window, "destroy" , G_CALLBACK (quit_cb), &done); |
169 | gtk_widget_show (widget: window); |
170 | |
171 | while (!done) |
172 | g_main_context_iteration (NULL, TRUE); |
173 | } |
174 | |