summaryrefslogtreecommitdiffstats
path: root/tests/interactive-panels/main.c
blob: 0b0faaad20ff5048ec898cde1a4504042f81ce0b (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
/* main.c
 *
 * Copyright 2018 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "config.h"

#include <stdlib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>

#include "shell/cc-application.h"
#include "shell/cc-panel-loader.h"
#include "shell/resources.h"
#include "test-panels-resources.h"

#include "gtp-dynamic-panel.h"
#include "gtp-header-widget.h"
#include "gtp-sidebar-widget.h"
#include "gtp-static-init.h"

/* Test panels */
static CcPanelLoaderVtable test_panels[] = {
  { "dynamic-panel",           gtp_dynamic_panel_get_type,  NULL                 },
  { "header-widget",           gtp_header_widget_get_type,  NULL                 },
  { "sidebar-widget",          gtp_sidebar_widget_get_type, NULL                 },
  { "static-init",             gtp_static_init_get_type,    gtp_static_init_func },
  { "toplevel-sidebar-widget", gtp_sidebar_widget_get_type, NULL                 },
};

static void
override_xdg_data_dirs (void)
{
  g_autoptr(GString) extended_xdg_data_dirs = NULL;
  const gchar *xdg_data_dirs;

  extended_xdg_data_dirs = g_string_new (".");
  xdg_data_dirs = g_getenv ("XDG_DATA_DIRS");

  if (xdg_data_dirs)
    g_string_append_printf (extended_xdg_data_dirs, ":%s", xdg_data_dirs);

  g_setenv ("XDG_DATA_DIRS", extended_xdg_data_dirs->str, TRUE);
}

gint
main (gint   argc,
      gchar *argv[])
{
  g_autoptr(GtkApplication) application = NULL;

  /* Manually register GResources */
  g_resources_register (gnome_control_center_get_resource ());
  g_resources_register (test_panels_get_resource ());

  /* Override the panels vtable with the test panels */
  cc_panel_loader_override_vtable (test_panels, G_N_ELEMENTS (test_panels));

  /* Override XDG_DATA_DIRS */
  override_xdg_data_dirs ();

  application = cc_application_new ();

  return g_application_run (G_APPLICATION (application), argc, argv);
}