GCC Code Coverage Report


Directory: ./
File: search-provider/control-center-search-provider.c
Date: 2024-05-04 07:58:27
Exec Total Coverage
Lines: 0 48 0.0%
Functions: 0 12 0.0%
Branches: 0 17 0.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2012 Giovanni Campagna <scampa.giovanni@gmail.com>
3 *
4 * The Control Center is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * The Control Center is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with the Control Center; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 *
18 */
19
20 #include "config.h"
21
22 #include <glib/gi18n.h>
23 #include <stdlib.h>
24
25 #include <gio/gio.h>
26
27 #include <shell/cc-panel-loader.h>
28 #include <shell/cc-shell-model.h>
29 #include "cc-search-provider.h"
30 #include "control-center-search-provider.h"
31
32 G_DEFINE_TYPE (CcSearchProviderApp, cc_search_provider_app, GTK_TYPE_APPLICATION);
33
34 #define INACTIVITY_TIMEOUT 60 * 1000 /* One minute, in milliseconds */
35
36 static gboolean
37 cc_search_provider_app_dbus_register (GApplication *application,
38 GDBusConnection *connection,
39 const gchar *object_path,
40 GError **error)
41 {
42 CcSearchProviderApp *self;
43
44 if (!G_APPLICATION_CLASS (cc_search_provider_app_parent_class)->dbus_register (application,
45 connection,
46 object_path,
47 error))
48 return FALSE;
49
50 self = CC_SEARCH_PROVIDER_APP (application);
51
52 return cc_search_provider_dbus_register (self->search_provider, connection,
53 object_path, error);
54 }
55
56 static void
57 cc_search_provider_app_dbus_unregister (GApplication *application,
58 GDBusConnection *connection,
59 const gchar *object_path)
60 {
61 CcSearchProviderApp *self;
62
63 self = CC_SEARCH_PROVIDER_APP (application);
64 if (self->search_provider)
65 cc_search_provider_dbus_unregister (self->search_provider, connection, object_path);
66
67 G_APPLICATION_CLASS (cc_search_provider_app_parent_class)->dbus_unregister (application,
68 connection,
69 object_path);
70 }
71
72 static void
73 cc_search_provider_app_dispose (GObject *object)
74 {
75 CcSearchProviderApp *self;
76
77 self = CC_SEARCH_PROVIDER_APP (object);
78
79 g_clear_object (&self->model);
80 g_clear_object (&self->search_provider);
81
82 G_OBJECT_CLASS (cc_search_provider_app_parent_class)->dispose (object);
83 }
84
85 static void
86 cc_search_provider_app_init (CcSearchProviderApp *self)
87 {
88 self->search_provider = cc_search_provider_new ();
89 g_application_set_inactivity_timeout (G_APPLICATION (self),
90 INACTIVITY_TIMEOUT);
91
92 /* HACK: get the inactivity timeout started */
93 g_application_hold (G_APPLICATION (self));
94 g_application_release (G_APPLICATION (self));
95 }
96
97 static void
98 cc_search_provider_app_startup (GApplication *application)
99 {
100 CcSearchProviderApp *self;
101
102 self = CC_SEARCH_PROVIDER_APP (application);
103
104 G_APPLICATION_CLASS (cc_search_provider_app_parent_class)->startup (application);
105
106 self->model = cc_shell_model_new ();
107 cc_panel_loader_fill_model (self->model);
108 }
109
110 static void
111 cc_search_provider_app_class_init (CcSearchProviderAppClass *klass)
112 {
113 GObjectClass *object_class = G_OBJECT_CLASS (klass);
114 GApplicationClass *app_class = G_APPLICATION_CLASS (klass);
115
116 object_class->dispose = cc_search_provider_app_dispose;
117
118 app_class->dbus_register = cc_search_provider_app_dbus_register;
119 app_class->dbus_unregister = cc_search_provider_app_dbus_unregister;
120 app_class->startup = cc_search_provider_app_startup;
121 }
122
123 CcShellModel *
124 cc_search_provider_app_get_model (CcSearchProviderApp *application)
125 {
126 return application->model;
127 }
128
129 CcSearchProviderApp *
130 cc_search_provider_app_get ()
131 {
132 static CcSearchProviderApp *singleton;
133
134 if (singleton)
135 return singleton;
136
137 singleton = g_object_new (CC_TYPE_SEARCH_PROVIDER_APP,
138 "application-id", "org.gnome.Settings.SearchProvider",
139 "flags", G_APPLICATION_IS_SERVICE,
140 NULL);
141
142 return singleton;
143 }
144
145 int main (int argc, char **argv)
146 {
147 GApplication *app;
148
149 app = G_APPLICATION (cc_search_provider_app_get ());
150 return g_application_run (app, argc, argv);
151 }
152