Skip to content

Commit

Permalink
Merge pull request zserge#8 from arabine/icon-tray-kde
Browse files Browse the repository at this point in the history
Find AppIndicator with PkgConfig, use more standard icon name, add some missing header includes
  • Loading branch information
dmikushin authored May 25, 2023
2 parents 7510696 + ca7f842 commit 7c34b5b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 16 deletions.
29 changes: 17 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR) # target_link_directories

project(tray C)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")


# Generate 'compile_commands.json' for clang_complete
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)


find_package (PkgConfig REQUIRED)


file(GLOB SRCS
${CMAKE_CURRENT_LIST_DIR}/*.h
${CMAKE_CURRENT_LIST_DIR}/*.ico
Expand All @@ -20,8 +26,7 @@ else()
find_library(COCOA Cocoa REQUIRED)
list(APPEND SRCS ${CMAKE_CURRENT_SOURCE_DIR}/tray_darwin.m)
else()
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(APPINDICATOR REQUIRED appindicator3-0.1)
find_package(APPINDICATOR REQUIRED)
list(APPEND SRCS ${CMAKE_CURRENT_SOURCE_DIR}/tray_linux.c)
endif()
endif()
Expand All @@ -36,15 +41,15 @@ if(WIN32)
endif()
else()
if(UNIX)
if(APPLE)
target_compile_definitions(tray PRIVATE TRAY_APPKIT=1)
target_link_libraries(tray PRIVATE ${COCOA})
else()
target_compile_options(tray PRIVATE ${APPINDICATOR_CFLAGS})
target_link_directories(tray PRIVATE ${APPINDICATOR_LIBRARY_DIRS})
target_compile_definitions(tray PRIVATE TRAY_APPINDICATOR=1)
target_link_libraries(tray PRIVATE ${APPINDICATOR_LIBRARIES})
endif()
if(APPLE)
target_compile_definitions(tray PRIVATE TRAY_APPKIT=1)
target_link_libraries(tray PRIVATE ${COCOA})
else()
target_compile_options(tray PRIVATE ${APPINDICATOR_CFLAGS})
target_link_directories(tray PRIVATE ${APPINDICATOR_LIBRARY_DIRS})
target_compile_definitions(tray PRIVATE TRAY_APPINDICATOR=1)
target_link_libraries(tray PRIVATE ${APPINDICATOR_LIBRARIES})
endif()
endif()
endif()

Expand Down
29 changes: 29 additions & 0 deletions cmake/FindAPPINDICATOR.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Remmina - The GTK+ Remote Desktop Client
#
# Copyright (C) 2011 Marc-Andre Moreau
# Copyright (C) 2014-2015 Antenore Gatta, Fabio Castelli, Giovanni Panozzo
# Copyright (C) 2016-2023 Antenore Gatta, Giovanni Panozzo
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.

include(FindPackageHandleStandardArgs)

PKG_CHECK_MODULES(APPINDICATOR ayatana-appindicator3-0.1)
IF( APPINDICATOR_FOUND )
SET(HAVE_AYATANAAPPINDICATOR 1)
ENDIF()

mark_as_advanced(APPINDICATOR_INCLUDE_DIR APPINDICATOR_LIBRARY)
4 changes: 2 additions & 2 deletions example.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "tray.h"

#if TRAY_APPINDICATOR
#define TRAY_ICON1 "indicator-messages"
#define TRAY_ICON2 "indicator-messages-new"
#define TRAY_ICON1 "mail-message-new"
#define TRAY_ICON2 "mail-message-new"
#elif TRAY_APPKIT
#define TRAY_ICON1 "icon.png"
#define TRAY_ICON2 "icon.png"
Expand Down
5 changes: 3 additions & 2 deletions tray_linux.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <gtk/gtk.h>
#include <libappindicator/app-indicator.h>
#include "tray.h"
#include <string.h>
#include <stddef.h>
#include <libayatana-appindicator/app-indicator.h>

#define TRAY_APPINDICATOR_ID "tray-id"

Expand Down

0 comments on commit 7c34b5b

Please sign in to comment.