summaryrefslogtreecommitdiff
path: root/src/nautilus-gtk4-helpers.c
blob: 8f9c7bd3569592aeb8c5c54a1b25114ae8f79e96 (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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#include "nautilus-gtk4-helpers.h"

void
adw_bin_set_child (AdwBin    *bin,
                   GtkWidget *child)
{
    g_assert (GTK_IS_BIN (bin));

    gtk_container_add (GTK_CONTAINER (bin), child);
}

void
gtk_button_set_child (GtkButton *button,
                      GtkWidget *child)
{
    g_assert (GTK_IS_BUTTON (button));

    gtk_container_add (GTK_CONTAINER (button), child);
}

void
gtk_menu_button_set_child (GtkMenuButton *menu_button,
                           GtkWidget     *child)
{
    g_assert (GTK_IS_MENU_BUTTON (menu_button));

    gtk_container_add (GTK_CONTAINER (menu_button), child);
}

void
gtk_box_append (GtkBox    *box,
                GtkWidget *child)
{
    g_assert (GTK_IS_BOX (box));

    gtk_container_add (GTK_CONTAINER (box), child);
}

void
gtk_box_remove (GtkBox    *box,
                GtkWidget *child)
{
    g_assert (GTK_IS_BOX (box));

    gtk_container_remove (GTK_CONTAINER (box), child);
}

void
gtk_overlay_set_child (GtkOverlay *overlay,
                       GtkWidget  *child)
{
    g_assert (GTK_IS_OVERLAY (overlay));

    gtk_container_add (GTK_CONTAINER (overlay), child);
}

void
gtk_scrolled_window_set_child (GtkScrolledWindow *scrolled_window,
                               GtkWidget         *child)
{
    g_assert (GTK_IS_SCROLLED_WINDOW (scrolled_window));

    gtk_container_add (GTK_CONTAINER (scrolled_window), child);
}

void
gtk_list_box_row_set_child (GtkListBoxRow *row,
                            GtkWidget     *child)
{
    g_assert (GTK_IS_LIST_BOX_ROW (row));

    gtk_container_add (GTK_CONTAINER (row), child);
}

void
gtk_info_bar_add_child (GtkInfoBar *info_bar,
                        GtkWidget  *widget)
{
    g_assert (GTK_IS_INFO_BAR (info_bar));

    gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (info_bar)),
                       widget);
}

void
gtk_revealer_set_child (GtkRevealer *revealer,
                        GtkWidget   *child)
{
    g_assert (GTK_IS_REVEALER (revealer));

    gtk_container_add (GTK_CONTAINER (revealer), child);
}

void
gtk_popover_set_child (GtkPopover *popover,
                       GtkWidget  *child)
{
    g_assert (GTK_IS_POPOVER (popover));

    gtk_container_add (GTK_CONTAINER (popover), child);
}

void
gtk_check_button_set_active (GtkCheckButton *button,
                             gboolean        setting)
{
    g_assert (GTK_IS_CHECK_BUTTON (button));

    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), setting);
}


void
gtk_center_box_set_start_widget (GtkCenterBox *center_box,
                                 GtkWidget    *widget)
{
    g_assert (GTK_IS_BOX (center_box));

    gtk_box_pack_start (GTK_BOX (center_box), widget, FALSE, TRUE, 0);
}

void
gtk_center_box_set_center_widget (GtkCenterBox *center_box,
                                  GtkWidget    *widget)
{
    g_assert (GTK_IS_BOX (center_box));

    gtk_box_set_center_widget (GTK_BOX (center_box), widget);
}
void
gtk_center_box_set_end_widget (GtkCenterBox *center_box,
                               GtkWidget    *widget)
{
    g_assert (GTK_IS_BOX (center_box));

    gtk_box_pack_end (GTK_BOX (center_box), widget, FALSE, TRUE, 0);
}

GtkWidget *
gtk_center_box_new (void)
{
    return gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
}

gboolean
gtk_check_button_get_active (GtkCheckButton *button)
{
    g_assert (GTK_IS_CHECK_BUTTON (button));

    return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
}

GtkWidget *
gtk_widget_get_first_child (GtkWidget *widget)
{
    g_autoptr (GList) children = NULL;

    g_assert (GTK_IS_CONTAINER (widget));

    children = gtk_container_get_children (GTK_CONTAINER (widget));
    if (children != NULL)
    {
        return GTK_WIDGET (children->data);
    }

    return NULL;
}

GtkWidget *
gtk_widget_get_focus_child (GtkWidget *widget)
{
    g_assert (GTK_IS_CONTAINER (widget));

    return gtk_container_get_focus_child (GTK_CONTAINER (widget));
}

GtkWidget *
gtk_scrolled_window_get_child (GtkScrolledWindow *scrolled)
{
    g_assert (GTK_IS_SCROLLED_WINDOW (scrolled));

    return gtk_bin_get_child (GTK_BIN (scrolled));
}

GdkDisplay *
gtk_root_get_display (GtkRoot *root)
{
    g_assert (GTK_IS_WINDOW (root));

    return gdk_screen_get_display (gtk_window_get_screen (GTK_WINDOW (root)));
}

void
gtk_window_set_display (GtkWindow  *window,
                        GdkDisplay *display)
{
    g_assert (GTK_IS_WINDOW (window));

    gtk_window_set_screen (window, gdk_display_get_default_screen (display));
}

void
gtk_style_context_add_provider_for_display (GdkDisplay       *display,
                                            GtkStyleProvider *provider,
                                            guint             priority)
{
    gtk_style_context_add_provider_for_screen (gdk_display_get_default_screen (display),
                                               provider,
                                               priority);
}

void
gtk_style_context_remove_provider_for_display (GdkDisplay       *display,
                                               GtkStyleProvider *provider)
{
    gtk_style_context_remove_provider_for_screen (gdk_display_get_default_screen (display),
                                                  provider);
}