summaryrefslogtreecommitdiff
path: root/capplets/common/activate-settings-daemon.c
blob: f82f0353dd0922862e946fc43dac4d51aad40831 (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
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <mate-settings-client.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>

#include "activate-settings-daemon.h"

static void popup_error_message (void)
{
  GtkWidget *dialog;

  dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING,
				   GTK_BUTTONS_OK, _("Unable to start the settings manager 'mate-settings-daemon'.\n"
				   "Without the MATE settings manager running, some preferences may not take effect. This could "
				   "indicate a problem with DBus, or a non-MATE (e.g. KDE) settings manager may already "
				   "be active and conflicting with the MATE settings manager."));

  gtk_dialog_run (GTK_DIALOG (dialog));
  gtk_widget_destroy (dialog);
}

/* Returns FALSE if activation failed, else TRUE */
gboolean 
activate_settings_daemon (void)
{
  DBusGConnection *connection = NULL;
  DBusGProxy *proxy = NULL;
  GError *error = NULL;

  connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
  if (connection == NULL)
    {
      popup_error_message ();
      g_error_free (error);
      return FALSE;
    }
    
  proxy = dbus_g_proxy_new_for_name (connection,
                                     "org.mate.SettingsDaemon",
                                     "/org/mate/SettingsDaemon",
                                     "org.mate.SettingsDaemon");

  if (proxy == NULL)
    {
      popup_error_message ();
      return FALSE;
    }

  if (!org_mate_SettingsDaemon_awake(proxy, &error))
    {
      popup_error_message ();
      g_error_free (error);
      return FALSE;
    }

  return TRUE;
}