From 6b6c2f9c7d92a7a505f1a54407590af0a329998e Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Mon, 2 Oct 2023 16:42:35 +0200 Subject: CMakeLists.txt: Some build warning fixes --- CMakeLists.txt | 6 ++---- src/libayatana-common.pc.in | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49c093b..2da6637 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -project (libayatana-common C CXX) -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required (VERSION 3.13) +project (libayatana-common VERSION "0.9.8" LANGUAGES C CXX) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}") @@ -7,8 +7,6 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) SET(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE) endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) -set(PROJECT_VERSION "0.9.8") -set(PACKAGE ${CMAKE_PROJECT_NAME}) set(GETTEXT_PACKAGE "ayatana-common") set(API_VERSION 0) set(ABI_VERSION 0) diff --git a/src/libayatana-common.pc.in b/src/libayatana-common.pc.in index df79e1f..4800e81 100644 --- a/src/libayatana-common.pc.in +++ b/src/libayatana-common.pc.in @@ -5,6 +5,6 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@/ayatana Name: Ayatana common Description: Ayatana common library -Version: @PROJECT_VERSION@ +Version: @CMAKE_PROJECT_VERSION@ Libs: -L${libdir} -layatana-common Cflags: -I${includedir} -- cgit v1.2.3 From 254ae9a5ef7d893f725456f5e25f9ec245acba5b Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Mon, 2 Oct 2023 16:51:12 +0200 Subject: Add an execute_command with warning --- src/CMakeLists.txt | 2 ++ src/utils.c | 37 +++++++++++++++++++++++++++++++++++-- src/utils.h | 4 ++-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee44f7a..c7d351d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,6 +7,8 @@ target_link_libraries(ayatana-common ${DEPS_LIBRARIES} ) +target_compile_definitions (ayatana-common PUBLIC GETTEXT_PACKAGE="${GETTEXT_PACKAGE}" LOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}") + if(ENABLE_LOMIRI_FEATURES) add_definitions( -DLOMIRI_FEATURES_ENABLED ) endif() diff --git a/src/utils.c b/src/utils.c index 95aa1ce..f6c113a 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,6 +1,6 @@ /* * Copyright 2021 Marius Gripsgard - * Copyright 2021 Robert Tari + * Copyright 2021-2023 Robert Tari * * 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 @@ -16,13 +16,25 @@ */ #include "utils.h" - +#include #include #ifdef LOMIRI_FEATURES_ENABLED # include #endif +static gboolean bI18nInit = FALSE; + +static void initI18n () +{ + if (!bI18nInit) + { + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + bI18nInit = TRUE; + } +} + // TODO: make case insensitive gboolean is_xdg_current_desktop (const gchar* desktop, const gchar* session) @@ -304,3 +316,24 @@ void ayatana_common_utils_ellipsize(char *sText) memcpy(pLastChar, "...\0", 4); } } + +gboolean ayatana_common_utils_execute_command_warn (const gchar *sProgram, const gchar *sArgs) +{ + gboolean bHasProgram = ayatana_common_utils_have_program (sProgram); + + if (!bHasProgram) + { + initI18n (); + gchar *sMessage = g_strdup_printf (_("The %s program is required for this action, but it was not found."), sProgram); + ayatana_common_utils_zenity_warning ("dialog-warning", _("Warning"), sMessage); + g_free (sMessage); + + return FALSE; + } + + gchar *sCommand = g_strdup_printf ("%s %s", sProgram, sArgs); + gboolean bSuccess = ayatana_common_utils_execute_command (sCommand); + g_free (sCommand); + + return bSuccess; +} diff --git a/src/utils.h b/src/utils.h index aaca08e..34cf2f4 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,6 +1,6 @@ /* * Copyright 2021 Marius Gripsgard - * Copyright 2021-2022 Robert Tari + * Copyright 2021-2023 Robert Tari * * 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 @@ -56,5 +56,5 @@ gboolean ayatana_common_utils_execute_command(const gchar * cmd); gboolean ayatana_common_utils_open_url(const gchar * url); gboolean ayatana_common_utils_have_program(const gchar * program); gboolean ayatana_common_utils_zenity_warning(const char *icon_name, const char *title, const char *text); - void ayatana_common_utils_ellipsize(char *sText); +gboolean ayatana_common_utils_execute_command_warn (const gchar *sProgram, const gchar *sArgs); -- cgit v1.2.3