Branch data Line data Source code
1 : : // SPDX-License-Identifier: GPL-3.0-or-later
2 : : // SPDX-FileCopyrightText: Andy Holmes <andrew.g.r.holmes@gmail.com>
3 : :
4 : : #define G_LOG_DOMAIN "valent-ui-main"
5 : :
6 : : #include "config.h"
7 : :
8 : : #include <adwaita.h>
9 : : #include <gtk/gtk.h>
10 : :
11 : : #include "valent-device-gadget.h"
12 : : #include "valent-device-page.h"
13 : : #include "valent-device-preferences-group.h"
14 : : #include "valent-device-preferences-dialog.h"
15 : : #include "valent-input-remote.h"
16 : : #include "valent-media-remote.h"
17 : : #include "valent-menu-list.h"
18 : : #include "valent-menu-stack.h"
19 : : #include "valent-preferences-page.h"
20 : : #include "valent-preferences-dialog.h"
21 : : #include "valent-ui-manager.h"
22 : : #include "valent-ui-utils.h"
23 : : #include "valent-window.h"
24 : :
25 : :
26 : : static void
27 : 35 : valent_ui_init_resources (void)
28 : : {
29 : 70 : g_autoptr (GtkCssProvider) css_theme = NULL;
30 [ + - ]: 35 : g_autoptr (GtkIconTheme) icon_theme = NULL;
31 : :
32 : 35 : css_theme = gtk_css_provider_new ();
33 : 35 : gtk_css_provider_load_from_resource (css_theme, "/ca/andyholmes/Valent/ui/style.css");
34 : 35 : gtk_style_context_add_provider_for_display (gdk_display_get_default (),
35 : : GTK_STYLE_PROVIDER (css_theme),
36 : : GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
37 : :
38 : 35 : icon_theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
39 [ + - ]: 35 : gtk_icon_theme_add_resource_path (icon_theme, "/ca/andyholmes/Valent/icons");
40 : 35 : }
41 : :
42 : : static void
43 : 35 : valent_ui_init_types (void)
44 : : {
45 : 35 : g_type_ensure (VALENT_TYPE_DEVICE_GADGET);
46 : 35 : g_type_ensure (VALENT_TYPE_DEVICE_PAGE);
47 : 35 : g_type_ensure (VALENT_TYPE_DEVICE_PREFERENCES_GROUP);
48 : 35 : g_type_ensure (VALENT_TYPE_DEVICE_PREFERENCES_DIALOG);
49 : 35 : g_type_ensure (VALENT_TYPE_INPUT_REMOTE);
50 : 35 : g_type_ensure (VALENT_TYPE_MEDIA_REMOTE);
51 : 35 : g_type_ensure (VALENT_TYPE_MENU_LIST);
52 : 35 : g_type_ensure (VALENT_TYPE_MENU_STACK);
53 : 35 : g_type_ensure (VALENT_TYPE_PREFERENCES_PAGE);
54 : 35 : g_type_ensure (VALENT_TYPE_PREFERENCES_DIALOG);
55 : 35 : g_type_ensure (VALENT_TYPE_UI_MANAGER);
56 : 35 : g_type_ensure (VALENT_TYPE_WINDOW);
57 : 35 : }
58 : :
59 : : /**
60 : : * valent_ui_init:
61 : : *
62 : : * Initialize Valent's default user interface.
63 : : *
64 : : * Returns: %TRUE if successful, or %FALSE on failure
65 : : *
66 : : * Since: 1.0
67 : : */
68 : : gboolean
69 : 35 : valent_ui_init (void)
70 : : {
71 : 35 : static gboolean initialized = -1;
72 : :
73 [ + - ]: 35 : if G_LIKELY (initialized != -1)
74 : : return initialized;
75 : :
76 [ + - ]: 35 : if ((initialized = gtk_init_check ()))
77 : : {
78 : 35 : adw_init ();
79 : :
80 : 35 : valent_ui_init_types ();
81 : 35 : valent_ui_init_resources ();
82 : : }
83 : :
84 : 35 : return initialized;
85 : : }
|