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-page.h"
12 : : #include "valent-device-row.h"
13 : : #include "valent-device-preferences-dialog.h"
14 : : #include "valent-gnome-application.h"
15 : : #include "valent-input-remote.h"
16 : : #include "valent-media-remote.h"
17 : : #include "valent-media-window.h"
18 : : #include "valent-menu-list.h"
19 : : #include "valent-menu-stack.h"
20 : : #include "valent-mixer-remote.h"
21 : : #include "valent-preferences-dialog.h"
22 : : #include "valent-preferences-page.h"
23 : : #include "valent-preferences-other-page.h"
24 : : #include "valent-preferences-status-page.h"
25 : : #include "valent-preferences-sync-page.h"
26 : : #include "valent-ui-utils-private.h"
27 : : #include "valent-window.h"
28 : :
29 : :
30 : : static void
31 : 17 : valent_ui_init_resources (void)
32 : : {
33 : 34 : g_autoptr (GtkCssProvider) css_theme = NULL;
34 [ + - ]: 17 : g_autoptr (GtkIconTheme) icon_theme = NULL;
35 : :
36 : 17 : css_theme = gtk_css_provider_new ();
37 : 17 : gtk_css_provider_load_from_resource (css_theme, "/plugins/gnome/style.css");
38 : 17 : gtk_style_context_add_provider_for_display (gdk_display_get_default (),
39 : : GTK_STYLE_PROVIDER (css_theme),
40 : : GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
41 : :
42 : 17 : icon_theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
43 [ + - ]: 17 : gtk_icon_theme_add_resource_path (icon_theme, "/ca/andyholmes/Valent/icons");
44 : 17 : }
45 : :
46 : : static void
47 : 17 : valent_ui_init_types (void)
48 : : {
49 : 17 : g_type_ensure (VALENT_TYPE_DEVICE_PAGE);
50 : 17 : g_type_ensure (VALENT_TYPE_DEVICE_ROW);
51 : 17 : g_type_ensure (VALENT_TYPE_DEVICE_PREFERENCES_DIALOG);
52 : 17 : g_type_ensure (VALENT_TYPE_GNOME_APPLICATION);
53 : 17 : g_type_ensure (VALENT_TYPE_INPUT_REMOTE);
54 : 17 : g_type_ensure (VALENT_TYPE_MEDIA_REMOTE);
55 : 17 : g_type_ensure (VALENT_TYPE_MEDIA_WINDOW);
56 : 17 : g_type_ensure (VALENT_TYPE_MENU_LIST);
57 : 17 : g_type_ensure (VALENT_TYPE_MENU_STACK);
58 : 17 : g_type_ensure (VALENT_TYPE_MIXER_REMOTE);
59 : 17 : g_type_ensure (VALENT_TYPE_PREFERENCES_DIALOG);
60 : 17 : g_type_ensure (VALENT_TYPE_PREFERENCES_PAGE);
61 : 17 : g_type_ensure (VALENT_TYPE_PREFERENCES_OTHER_PAGE);
62 : 17 : g_type_ensure (VALENT_TYPE_PREFERENCES_STATUS_PAGE);
63 : 17 : g_type_ensure (VALENT_TYPE_PREFERENCES_SYNC_PAGE);
64 : 17 : g_type_ensure (VALENT_TYPE_WINDOW);
65 : 17 : }
66 : :
67 : : /**
68 : : * valent_ui_init:
69 : : *
70 : : * Initialize Valent's default user interface.
71 : : *
72 : : * Returns: %TRUE if successful, or %FALSE on failure
73 : : *
74 : : * Since: 1.0
75 : : */
76 : : gboolean
77 : 27 : valent_ui_init (void)
78 : : {
79 : 27 : static gboolean initialized = -1;
80 : :
81 [ + + ]: 27 : if G_LIKELY (initialized != -1)
82 : : return initialized;
83 : :
84 [ + - ]: 17 : if ((initialized = gtk_init_check ()))
85 : : {
86 : 17 : adw_init ();
87 : :
88 : 17 : valent_ui_init_types ();
89 : 17 : valent_ui_init_resources ();
90 : : }
91 : :
92 : 17 : return initialized;
93 : : }
94 : :
|