1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 */
21
22 #include "config.h"
23
24 #include <glib/gi18n-lib.h>
25 #include <gmodule.h>
26
27 #include "mate-settings-plugin.h"
28 #include "msd-xrdb-plugin.h"
29 #include "msd-xrdb-manager.h"
30
31 struct MsdXrdbPluginPrivate {
32 MsdXrdbManager *manager;
33 };
34
MATE_SETTINGS_PLUGIN_REGISTER_WITH_PRIVATE(MsdXrdbPlugin,msd_xrdb_plugin)35 MATE_SETTINGS_PLUGIN_REGISTER_WITH_PRIVATE (MsdXrdbPlugin, msd_xrdb_plugin)
36
37 static void
38 msd_xrdb_plugin_init (MsdXrdbPlugin *plugin)
39 {
40 plugin->priv = msd_xrdb_plugin_get_instance_private (plugin);
41
42 g_debug ("MsdXrdbPlugin initializing");
43
44 plugin->priv->manager = msd_xrdb_manager_new ();
45 }
46
47 static void
msd_xrdb_plugin_finalize(GObject * object)48 msd_xrdb_plugin_finalize (GObject *object)
49 {
50 MsdXrdbPlugin *plugin;
51
52 g_return_if_fail (object != NULL);
53 g_return_if_fail (MSD_IS_XRDB_PLUGIN (object));
54
55 g_debug ("MsdXrdbPlugin finalizing");
56
57 plugin = MSD_XRDB_PLUGIN (object);
58
59 g_return_if_fail (plugin->priv != NULL);
60
61 if (plugin->priv->manager != NULL) {
62 g_object_unref (plugin->priv->manager);
63 }
64
65 G_OBJECT_CLASS (msd_xrdb_plugin_parent_class)->finalize (object);
66 }
67
68 static void
impl_activate(MateSettingsPlugin * plugin)69 impl_activate (MateSettingsPlugin *plugin)
70 {
71 gboolean res;
72 GError *error;
73
74 g_debug ("Activating xrdb plugin");
75
76 error = NULL;
77 res = msd_xrdb_manager_start (MSD_XRDB_PLUGIN (plugin)->priv->manager, &error);
78 if (! res) {
79 g_warning ("Unable to start xrdb manager: %s", error->message);
80 g_error_free (error);
81 }
82 }
83
84 static void
impl_deactivate(MateSettingsPlugin * plugin)85 impl_deactivate (MateSettingsPlugin *plugin)
86 {
87 g_debug ("Deactivating xrdb plugin");
88 msd_xrdb_manager_stop (MSD_XRDB_PLUGIN (plugin)->priv->manager);
89 }
90
91 static void
msd_xrdb_plugin_class_init(MsdXrdbPluginClass * klass)92 msd_xrdb_plugin_class_init (MsdXrdbPluginClass *klass)
93 {
94 GObjectClass *object_class = G_OBJECT_CLASS (klass);
95 MateSettingsPluginClass *plugin_class = MATE_SETTINGS_PLUGIN_CLASS (klass);
96
97 object_class->finalize = msd_xrdb_plugin_finalize;
98
99 plugin_class->activate = impl_activate;
100 plugin_class->deactivate = impl_deactivate;
101 }
102
103 static void
msd_xrdb_plugin_class_finalize(MsdXrdbPluginClass * klass)104 msd_xrdb_plugin_class_finalize (MsdXrdbPluginClass *klass)
105 {
106 }
107
108