This repository was archived by the owner on Aug 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgtk-compat.h
92 lines (76 loc) · 2.41 KB
/
gtk-compat.h
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
#ifndef GTK_COMPAT_H
#define GTK_COMPAT_H
#define GtkGrid GtkTable
#define GTK_GRID GTK_TABLE
#define gtk_grid_set_row_spacing gtk_table_set_row_spacings
#define gtk_grid_set_column_spacing gtk_table_set_col_spacings
static inline GtkWidget *
gtk_box_new (GtkOrientation orientation,
gint spacing)
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
return gtk_hbox_new (FALSE, spacing);
else
return gtk_vbox_new (FALSE, spacing);
}
static inline GtkWidget *
gtk_separator_new (GtkOrientation orientation)
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
return gtk_hseparator_new ();
else
return gtk_vseparator_new ();
}
static inline GtkWidget *
gtk_grid_new (void)
{
return gtk_table_new (1, 1, FALSE);
}
static inline void
gtk_grid_attach (GtkGrid *grid,
GtkWidget *child,
gint left,
gint top,
gint width,
gint height)
{
gtk_table_attach (grid, child, left, left + width, top, top + height,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
}
static inline guint
gtk_builder_add_from_resource (GtkBuilder *builder,
const gchar *resource_path,
GError **error)
{
GBytes *data;
guint ret;
data = g_resources_lookup_data (resource_path, 0, error);
if (data == NULL)
return 0;
ret = gtk_builder_add_from_string (builder,
g_bytes_get_data (data, NULL),
g_bytes_get_size (data),
error);
g_bytes_unref (data);
return ret;
}
static inline guint
gtk_builder_add_objects_from_resource (GtkBuilder *builder,
const gchar *resource_path,
gchar **object_ids,
GError **error)
{
GBytes *data;
guint ret;
data = g_resources_lookup_data (resource_path, 0, error);
if (data == NULL)
return 0;
ret = gtk_builder_add_objects_from_string (builder,
g_bytes_get_data (data, NULL),
g_bytes_get_size (data),
object_ids,
error);
g_bytes_unref (data);
return ret;
}
#endif