From 85b752c39eb47ee926f23e9d33a0990f6738e01a Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Thu, 25 Mar 2021 14:17:37 +0100 Subject: Move redundant code portions into libayatana-common and build against it. --- src/service.c | 2 +- src/utils.c | 121 +--------------------------------------------------------- src/utils.h | 7 ---- 3 files changed, 2 insertions(+), 128 deletions(-) (limited to 'src') diff --git a/src/service.c b/src/service.c index d7b4649..af46b87 100644 --- a/src/service.c +++ b/src/service.c @@ -20,7 +20,7 @@ #include #include - +#include #include "brightness.h" #include "dbus-shared.h" #include "device.h" diff --git a/src/utils.c b/src/utils.c index 82c5cf7..16dd776 100644 --- a/src/utils.c +++ b/src/utils.c @@ -19,27 +19,13 @@ * with this program. If not, see . */ +#include #include "utils.h" #ifdef HAS_URLDISPATCHER # include #endif -/* Run a particular program based on an activation */ -void -execute_command (const gchar * cmd) -{ - GError * err = NULL; - - g_debug ("Issuing command '%s'", cmd); - - if (!g_spawn_command_line_async (cmd, &err)) - { - g_warning ("Unable to start %s: %s", cmd, err->message); - g_error_free (err); - } -} - gboolean zenity_warning (const char * icon_name, const char * title, @@ -139,108 +125,3 @@ utils_handle_settings_request (void) execute_command(control_center_cmd); } } - -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; -} - -gboolean -is_xfce () -{ - 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], "XFCE")) { - g_strfreev (desktop_names); - return TRUE; - } - } - g_strfreev (desktop_names); - } - return FALSE; -} - -gboolean -is_pantheon () -{ - 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], "Pantheon")) { - g_strfreev (desktop_names); - return TRUE; - } - } - g_strfreev (desktop_names); - } - return FALSE; -} diff --git a/src/utils.h b/src/utils.h index 2666f02..7d03abb 100644 --- a/src/utils.h +++ b/src/utils.h @@ -21,15 +21,8 @@ #include #include -void execute_command (const gchar * cmd); void utils_handle_settings_request(void); gboolean zenity_warning (const char * icon_name, const char * title, const char * text); -gboolean is_unity(); -gboolean is_gnome(); -gboolean is_mate(); -gboolean is_pantheon(); -gboolean is_xfce(); - #endif /* __INDICATOR_POWER_UTILS_H__ */ -- cgit v1.2.3