aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-05-30 11:56:07 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-05-30 11:59:27 +0200
commit4e4971719bc0f49c07905cab802b861281562edc (patch)
tree2f7e6b031474221ad75efe5adee20109ce40fd7c
parent2eb2c1eeecf1d79e45e1007f7487f2675850b9f1 (diff)
downloadayatana-indicator-session-4e4971719bc0f49c07905cab802b861281562edc.tar.gz
ayatana-indicator-session-4e4971719bc0f49c07905cab802b861281562edc.tar.bz2
ayatana-indicator-session-4e4971719bc0f49c07905cab802b861281562edc.zip
src/utils.[ch]: Make desktop env checks available globally, load MSD media keys settings, if in MATE environment.
-rw-r--r--debian/control2
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/backend-dbus/actions.c65
-rw-r--r--src/backend-dbus/actions.h1
-rw-r--r--src/service.c9
-rw-r--r--src/utils.c80
-rw-r--r--src/utils.h26
7 files changed, 120 insertions, 67 deletions
diff --git a/debian/control b/debian/control
index f5cfe3c..1606073 100644
--- a/debian/control
+++ b/debian/control
@@ -20,7 +20,7 @@ Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends},
systemd,
- gnome-settings-daemon,
+ gnome-settings-daemon | mate-settings-daemon,
gsettings-desktop-schemas,
ayatana-indicator-common,
Recommends: indicator-applet (>= 0.2) | mate-indicator-applet | indicator-renderer,
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 111a3e2..9653e3a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,7 +10,9 @@ add_library (libayatanaindicatorsessionservice STATIC
service.c
service.h
users.c
- users.h)
+ users.h
+ utils.c
+ utils.h)
include_directories(${SERVICE_INCLUDE_DIRS})
link_directories(${SERVICE_LIBRARY_DIRS})
diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c
index 3965865..33305d9 100644
--- a/src/backend-dbus/actions.c
+++ b/src/backend-dbus/actions.c
@@ -29,6 +29,8 @@
#include "actions.h"
+#include "../utils.h"
+
enum
{
END_SESSION_TYPE_LOGOUT = 0,
@@ -81,69 +83,6 @@ log_and_clear_error (GError ** err, const char * loc, const char * func)
}
}
-static gboolean
-is_unity ()
-{
- const gchar *xdg_current_desktop;
- gchar **desktop_names;
- int i;
-
- xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
- if (xdg_current_desktop != NULL) {
- desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
- for (i = 0; desktop_names[i]; ++i) {
- if (!g_strcmp0 (desktop_names[i], "Unity")) {
- g_strfreev (desktop_names);
- return TRUE;
- }
- }
- g_strfreev (desktop_names);
- }
- return FALSE;
-}
-
-static gboolean
-is_gnome ()
-{
- const gchar *xdg_current_desktop;
- gchar **desktop_names;
- int i;
-
- xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
- if (xdg_current_desktop != NULL) {
- desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
- for (i = 0; desktop_names[i]; ++i) {
- if (!g_strcmp0 (desktop_names[i], "GNOME")) {
- g_strfreev (desktop_names);
- return TRUE;
- }
- }
- g_strfreev (desktop_names);
- }
- return FALSE;
-}
-
-static gboolean
-is_mate ()
-{
- const gchar *xdg_current_desktop;
- gchar **desktop_names;
- int i;
-
- xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
- if (xdg_current_desktop != NULL) {
- desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
- for (i = 0; desktop_names[i]; ++i) {
- if (!g_strcmp0 (desktop_names[i], "MATE")) {
- g_strfreev (desktop_names);
- return TRUE;
- }
- }
- g_strfreev (desktop_names);
- }
- return FALSE;
-}
-
/***
****
diff --git a/src/backend-dbus/actions.h b/src/backend-dbus/actions.h
index d3d722d..97d816a 100644
--- a/src/backend-dbus/actions.h
+++ b/src/backend-dbus/actions.h
@@ -64,7 +64,6 @@ void indicator_session_actions_dbus_set_proxies (IndicatorSessionActionsDbus * s
Login1Manager * login1_manager,
Login1Seat * login1_seat,
DisplayManagerSeat * dm_seat);
-
G_END_DECLS
diff --git a/src/service.c b/src/service.c
index 46c3c19..401bc56 100644
--- a/src/service.c
+++ b/src/service.c
@@ -24,6 +24,8 @@
#include "recoverable-problem.h"
#include "service.h"
+#include "utils.h"
+
#define BUS_NAME "org.ayatana.indicator.session"
#define BUS_PATH "/org/ayatana/indicator/session"
@@ -1235,7 +1237,12 @@ indicator_session_service_init (IndicatorSessionService * self)
INDICATOR_TYPE_SESSION_SERVICE,
IndicatorSessionServicePrivate);
p->indicator_settings = g_settings_new ("org.ayatana.indicator.session");
- p->keybinding_settings = g_settings_new ("org.gnome.settings-daemon.plugins.media-keys");
+ if (is_mate())
+ p->keybinding_settings = g_settings_new ("org.mate.SettingsDaemon.plugins.media-keys");
+
+ else if (is_gnome() || is_unity())
+ p->keybinding_settings = g_settings_new ("org.gnome.settings-daemon.plugins.media-keys");
+
self->priv = p;
/* init the backend objects */
diff --git a/src/utils.c b/src/utils.c
new file mode 100644
index 0000000..30ce341
--- /dev/null
+++ b/src/utils.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2017 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, 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/>.
+ */
+
+#include "utils.h"
+
+gboolean
+is_unity ()
+{
+ const gchar *xdg_current_desktop;
+ gchar **desktop_names;
+ int i;
+
+ xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
+ if (xdg_current_desktop != NULL) {
+ desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
+ for (i = 0; desktop_names[i]; ++i) {
+ if (!g_strcmp0 (desktop_names[i], "Unity")) {
+ g_strfreev (desktop_names);
+ return TRUE;
+ }
+ }
+ g_strfreev (desktop_names);
+ }
+ return FALSE;
+}
+
+gboolean
+is_gnome ()
+{
+ const gchar *xdg_current_desktop;
+ gchar **desktop_names;
+ int i;
+
+ xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
+ if (xdg_current_desktop != NULL) {
+ desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
+ for (i = 0; desktop_names[i]; ++i) {
+ if (!g_strcmp0 (desktop_names[i], "GNOME")) {
+ g_strfreev (desktop_names);
+ return TRUE;
+ }
+ }
+ g_strfreev (desktop_names);
+ }
+ return FALSE;
+}
+
+gboolean
+is_mate ()
+{
+ const gchar *xdg_current_desktop;
+ gchar **desktop_names;
+ int i;
+
+ xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
+ if (xdg_current_desktop != NULL) {
+ desktop_names = g_strsplit (xdg_current_desktop, ":", 0);
+ for (i = 0; desktop_names[i]; ++i) {
+ if (!g_strcmp0 (desktop_names[i], "MATE")) {
+ g_strfreev (desktop_names);
+ return TRUE;
+ }
+ }
+ g_strfreev (desktop_names);
+ }
+ return FALSE;
+}
diff --git a/src/utils.h b/src/utils.h
new file mode 100644
index 0000000..f431f85
--- /dev/null
+++ b/src/utils.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2017 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, 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/>.
+ */
+
+#ifndef __INDICATOR_SESSION_UTILS_H__
+#define __INDICATOR_SESSION_UTILS_H__
+
+#include <glib.h>
+
+gboolean is_unity();
+gboolean is_gnome();
+gboolean is_mate();
+
+#endif /* __INDICATOR_SESSION_UTILS_H__ */