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

#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <gio/gio.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)
{
  GError     *error = NULL;
  GDBusProxy *proxy = NULL;
  GVariant *ret;

  proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
                                         G_DBUS_PROXY_FLAGS_NONE,
                                         NULL,
                                         "org.mate.SettingsDaemon",
                                         "/org/mate/SettingsDaemon",
                                         "org.mate.SettingsDaemon",
                                         NULL,
                                         &error);
  if (proxy == NULL) {
    popup_error_message ();
    g_error_free (error);
    return FALSE;
  }

  ret = g_dbus_proxy_call_sync (proxy,
                                "Awake",
                                g_variant_new ("()"),
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL,
                                &error);
  if (ret == NULL) {
    popup_error_message ();
    g_error_free (error);
    return FALSE;
  } else {
    g_variant_get (ret, "()");
    g_variant_unref (ret);
  }

  return TRUE;
}