diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-05-03 22:29:40 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-05-03 22:29:40 +0200 |
commit | 03e887abe5945aa214de52ce2a9a2a82471024e6 (patch) | |
tree | e781544fc8c92a8d23b8c60c6f83eb6ff0bf0508 /src | |
parent | 4c50f67123792904e93920283f467c88f941d2e3 (diff) | |
parent | 9fefd2eee98c87c0a6a4561ca5268f246913c290 (diff) | |
download | ayatana-indicator-power-03e887abe5945aa214de52ce2a9a2a82471024e6.tar.gz ayatana-indicator-power-03e887abe5945aa214de52ce2a9a2a82471024e6.tar.bz2 ayatana-indicator-power-03e887abe5945aa214de52ce2a9a2a82471024e6.zip |
Merge branch 'tari01-pr/add-libayatana-common'
Attributes GH PR #22: https://github.com/AyatanaIndicators/ayatana-indicator-power/pull/22
Diffstat (limited to 'src')
-rw-r--r-- | src/service.c | 4 | ||||
-rw-r--r-- | src/utils.c | 122 | ||||
-rw-r--r-- | src/utils.h | 8 |
3 files changed, 6 insertions, 128 deletions
diff --git a/src/service.c b/src/service.c index d7b4649..c0e554e 100644 --- a/src/service.c +++ b/src/service.c @@ -1,9 +1,11 @@ /* * Copyright 2013 Canonical Ltd. + * Copytight 2021 AyatanaIndicators * * Authors: * Charles Kerr <charles.kerr@canonical.com> * Ted Gould <ted@canonical.com> + * Robert Tari <robert@tari.in> * * 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 @@ -20,7 +22,7 @@ #include <glib/gi18n.h> #include <gio/gio.h> - +#include <ayatana/common/utils.h> #include "brightness.h" #include "dbus-shared.h" #include "device.h" diff --git a/src/utils.c b/src/utils.c index 82c5cf7..8c2964b 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,6 +1,7 @@ /* * Copyright 2013 Canonical Ltd. * Copytight 2018 Mike Gabriel <mike.gabriel@das-netzwerkteam.de> + * Copytight 2021 Robert Tari <robert@tari.in> * * Authors (@Canonical): * Charles Kerr <charles.kerr@canonical.com> @@ -19,27 +20,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <ayatana/common/utils.h> #include "utils.h" #ifdef HAS_URLDISPATCHER # include <lomiri-url-dispatcher.h> #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 +126,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..2eb0de7 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,5 +1,6 @@ /* * Copytight 2018 Mike Gabriel <mike.gabriel@das-netzwerkteam.de> + * Copytight 2021 Robert Tari <robert@tari.in> * * 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 @@ -21,15 +22,8 @@ #include <glib/gi18n.h> #include <string.h> -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__ */ |