aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-09-09 16:14:36 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-09-09 16:14:36 +0200
commit4e27c33799a898e435a3a477838bcd88ef2d8b72 (patch)
treeb74dad8a8bb6b867d48448f2de51c4cd395d8c6c
parentce72a2c93d36789bb406d9053996396eeaa0dc56 (diff)
parentd42da41264e8e7a8939068791e9bb5038bdaf649 (diff)
downloadayatana-indicator-keyboard-4e27c33799a898e435a3a477838bcd88ef2d8b72.tar.gz
ayatana-indicator-keyboard-4e27c33799a898e435a3a477838bcd88ef2d8b72.tar.bz2
ayatana-indicator-keyboard-4e27c33799a898e435a3a477838bcd88ef2d8b72.zip
Merge branch 'tari01-pr/use-libayatana-common'
Attributes GH PR #16: https://github.com/AyatanaIndicators/ayatana-indicator-keyboard/pull/16
-rw-r--r--.build.yml17
-rw-r--r--CMakeLists.txt2
-rw-r--r--debian/control1
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/service.c6
-rw-r--r--src/utils.c167
-rw-r--r--src/utils.h38
7 files changed, 21 insertions, 212 deletions
diff --git a/.build.yml b/.build.yml
index 4d8c04d9..7265d2cb 100644
--- a/.build.yml
+++ b/.build.yml
@@ -17,6 +17,7 @@ requires:
- glib2
- libx11
- libxklavier
+# - libayatana-common
debian:
# Useful URL: https://salsa.debian.org/debian-ayatana-team/ayatana-ido
@@ -34,6 +35,7 @@ requires:
- libx11-dev
- libxklavier-dev
- systemd
+# - libayatana-common-dev
ubuntu:
- autopoint
@@ -49,6 +51,7 @@ requires:
- libx11-dev
- libxklavier-dev
- systemd
+# - libayatana-common-dev
variables:
- 'CHECKERS="
@@ -68,6 +71,16 @@ variables:
-enable-checker alpha.core.FixedAddr
-enable-checker security.insecureAPI.strcpy"'
+before_scripts:
+ - cd ${START_DIR}
+ - if [ ! -d libayatana-common-build ]; then
+ - git clone --depth 1 https://github.com/AyatanaIndicators/libayatana-common.git libayatana-common-build
+ - fi
+ - cd libayatana-common-build
+ - cmake . -DCMAKE_INSTALL_PREFIX=/usr
+ - make
+ - make install
+
build_scripts:
- if [ ${DISTRO_NAME} == "debian" ];then
- export CFLAGS+=" -Wsign-compare -Wunused-parameter"
@@ -78,7 +91,7 @@ build_scripts:
- NOCONFIGURE=1 ./autogen.sh
- scan-build $CHECKERS ./configure --prefix=/usr --enable-gtk-doc --enable-compile-warnings=maximum
- elif [ -e ./CMakeLists.txt ]; then
- - if [ ${DISTRO_NAME} == "debian" ];then
+ - if [ ${DISTRO_NAME} == "debian" ] || [ ${DISTRO_NAME} == "ubuntu" ]; then
- scan-build $CHECKERS cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTS=ON
- else
- scan-build $CHECKERS cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON
@@ -104,7 +117,7 @@ build_scripts:
#after_scripts:
# - if [ ${BUILD_TYPE} == "scripts" ];then
# - XVFB_RUN="$(which xvfb-run || true)"
-# - if [ ${DISTRO_NAME} == "debian" ];then
+# - if [ ${DISTRO_NAME} == "debian" ] || [ ${DISTRO_NAME} == "ubuntu" ];then
# - if [ -e ./autogen.sh ]; then
# - ${XVFB_RUN} make check
# - elif [ -e ./CMakeLists.txt ]; then
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 45149409..a9053180 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,7 +39,7 @@ add_definitions (-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}" -DLOCALEDIR="${CMAKE_INS
find_package (PkgConfig REQUIRED)
include (CheckIncludeFile)
include (FindPkgConfig)
-pkg_check_modules(SERVICE_DEPS REQUIRED glib-2.0>=2.36 gio-2.0>=2.36 x11>=1.6.7 libxklavier>=5.4)
+pkg_check_modules(SERVICE_DEPS REQUIRED glib-2.0>=2.36 gio-2.0>=2.36 x11>=1.6.7 libxklavier>=5.4 libayatana-common>=0.9.3)
include_directories (SYSTEM ${SERVICE_DEPS_INCLUDE_DIRS})
# custom targets
diff --git a/debian/control b/debian/control
index 8afa5797..2f401e8f 100644
--- a/debian/control
+++ b/debian/control
@@ -7,6 +7,7 @@ Build-Depends: cmake,
libglib2.0-dev (>= 2.36),
libx11-dev (>=1.7.0),
libxklavier-dev (>=5.4),
+ libayatana-common-dev (>= 0.9.3),
# for packaging
debhelper (>= 10),
dh-systemd | hello,
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3eb7caf9..6efa4677 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,7 +5,7 @@ set (SERVICE_EXEC "ayatana-indicator-keyboard-service")
add_definitions(-DG_LOG_DOMAIN="ayatana-indicator-keyboard")
# handwritten sources
-set(SERVICE_MANUAL_SOURCES keyboard.c service.c utils.c)
+set(SERVICE_MANUAL_SOURCES keyboard.c service.c)
# generated sources
set(SERVICE_GENERATED_SOURCES)
diff --git a/src/service.c b/src/service.c
index 8d662a20..afeed80f 100644
--- a/src/service.c
+++ b/src/service.c
@@ -16,8 +16,8 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
+#include <ayatana/common/utils.h>
#include "service.h"
-#include "utils.h"
#define BUS_NAME "org.ayatana.indicator.keyboard"
#define BUS_PATH "/org/ayatana/indicator/keyboard"
@@ -256,9 +256,9 @@ static void onLayoutSelected(GSimpleAction *pAction, GVariant *pVariant, gpointe
static void onSettings(GSimpleAction *pAction, GVariant *pVariant, gpointer pUserData)
{
- if (is_mate())
+ if (ayatana_common_utils_is_mate())
{
- execute_command("mate-keyboard-properties");
+ ayatana_common_utils_execute_command("mate-keyboard-properties");
}
}
diff --git a/src/utils.c b/src/utils.c
deleted file mode 100644
index 82f9cff0..00000000
--- a/src/utils.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2021 Marius Gripsgard <marius@ubports.com>
- *
- * 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"
-
-#include <string.h>
-
-#ifdef HAS_URLDISPATCHER
-# include <url-dispatcher.h>
-#endif
-
-// TODO: make case insensitive
-gboolean
-is_xdg_current_desktop (const gchar* desktop)
-{
- 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], desktop)) {
- g_strfreev (desktop_names);
- return TRUE;
- }
- }
- g_strfreev (desktop_names);
- }
- return FALSE;
-}
-
-gboolean
-is_lomiri ()
-{
- // For legacy reasons keep the MIR_SOCKET hack
- return (g_getenv ("MIR_SOCKET") != NULL ||
- is_xdg_current_desktop(DESKTOP_LOMIRI));
-}
-
-gboolean
-is_gnome ()
-{
- return is_xdg_current_desktop(DESKTOP_GNOME);
-}
-
-gboolean
-is_unity ()
-{
- return is_xdg_current_desktop(DESKTOP_UNITY);
-}
-
-gboolean
-is_mate ()
-{
- return is_xdg_current_desktop(DESKTOP_MATE);
-}
-
-gboolean
-is_xfce ()
-{
- return is_xdg_current_desktop(DESKTOP_XFCE);
-}
-
-gboolean
-is_pantheon ()
-{
- return is_xdg_current_desktop(DESKTOP_PANTHEON);
-}
-
-// Bit of a hacky way? should use xdg open
-char *
-find_browser ()
-{
- static char * browser_path = NULL;
- char* tmp_browser_path;
- gchar **browser_names;
-
- int i;
-
- if (browser_path == NULL)
- {
- browser_names = g_strsplit ("x-www-browser,google-chrome,firefox,chromium", ",", 0);
-
- for (i = 0; browser_names[i]; ++i) {
- tmp_browser_path = g_find_program_in_path (browser_names[i]);
-
- if (tmp_browser_path) {
- browser_path = g_strdup (tmp_browser_path);
- g_free (tmp_browser_path);
- g_strfreev (browser_names);
- break;
- }
- }
- }
-
- return browser_path;
-}
-
-gboolean
-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);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-open_url (const gchar * url)
-{
- char * browser = NULL;
-
- if (is_lomiri())
- {
-#ifdef HAS_URLDISPATCHER
- url_dispatch_send("settings:///system/battery", NULL, NULL);
- return TRUE;
-#else
- g_warning("Built without url-dispatcher, is not able to open url");
-#endif
- }
-
- if (browser == NULL)
- browser = find_browser();
-
- if (browser != NULL)
- return execute_command(g_strdup_printf("%s '%s'", browser, url));
- else
- return FALSE;
-
-}
-
-gboolean
-have_program (const gchar * program)
-{
- gchar *path;
- gboolean have;
-
- path = g_find_program_in_path(program);
- have = path != NULL;
- g_free(path);
-
- return have;
-}
diff --git a/src/utils.h b/src/utils.h
deleted file mode 100644
index 52e491f2..00000000
--- a/src/utils.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2021 Marius Gripsgard <marius@ubports.com>
- *
- * 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/>.
- */
-
-
-#pragma once
-
-#include <glib.h>
-
-#define DESKTOP_LOMIRI "Lomiri"
-#define DESKTOP_UNITY "Unity"
-#define DESKTOP_MATE "MATE"
-#define DESKTOP_GNOME "GNOME"
-#define DESKTOP_XFCE "XFCE"
-#define DESKTOP_PANTHEON "PANTHEON"
-
-gboolean is_lomiri();
-gboolean is_unity();
-gboolean is_gnome();
-gboolean is_mate();
-gboolean is_xfce();
-gboolean is_pantheon();
-
-gboolean execute_command(const gchar * cmd);
-gboolean open_url(const gchar * url);
-gboolean have_program(const gchar * program);