Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tray
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav
tray
Commits
268a2ccc
Commit
268a2ccc
authored
Jul 07, 2023
by
kimidaisuki22
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for linux.
parent
34763fc8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
11 deletions
+24
-11
CMakeLists.txt
CMakeLists.txt
+7
-1
example_pp.cpp
example/example_pp.cpp
+9
-2
linux.h
include/tray/platform/linux.h
+6
-6
tray_impl.h
include/tray/platform/tray_impl.h
+2
-2
No files found.
CMakeLists.txt
View file @
268a2ccc
...
...
@@ -12,10 +12,16 @@ target_include_directories(tray
if
(
UNIX AND NOT APPLE
)
find_package
(
PkgConfig REQUIRED
)
pkg_check_modules
(
APPINDICATOR REQUIRED appindicator3-0.1
)
message
(
STATUS
"To install appindicator3[ayatana-appindicator3-0.1], sudo apt install libayatana-appindicator3-dev"
)
pkg_check_modules
(
APPINDICATOR REQUIRED ayatana-appindicator3-0.1
)
target_compile_options
(
tray PRIVATE
${
APPINDICATOR_CFLAGS
}
)
target_link_libraries
(
tray PRIVATE
${
APPINDICATOR_LIBRARIES
}
)
target_link_directories
(
tray PRIVATE
${
APPINDICATOR_LIBRARY_DIRS
}
)
pkg_check_modules
(
GTK REQUIRED gtk+-3.0
)
target_compile_options
(
tray PRIVATE
${
GTK_CFLAGS
}
)
target_link_libraries
(
tray PRIVATE
${
GTK_LIBRARIES
}
)
target_link_directories
(
tray PRIVATE
${
GTK_LIBRARY_DIRS
}
)
elseif
(
APPLE
)
target_link_libraries
(
tray PRIVATE
"-framework Cocoa"
)
endif
()
...
...
example/example_pp.cpp
View file @
268a2ccc
#include "tray/tray.h"
#include <filesystem>
#include <stdlib.h>
int
main
()
{
trays
::
Menu
m
;
m
.
text_
=
"Open work dir"
;
m
.
on_click_
=
[](
auto
)
{
system
(
"start ."
);
};
trays
::
Tray
t
{
"icon.ico"
,
{
m
}};
m
.
on_click_
=
[](
auto
)
{
system
(
"open ."
);
};
// absolute path for linux.
// linux: png, svg
std
::
string
icon_name
=
"icon.png"
;
auto
icon_path
=
std
::
filesystem
::
current_path
()
/
icon_name
;
trays
::
Tray
t
{
icon_path
.
string
(),
{
m
}};
// t.add(m);
t
.
run
();
}
\ No newline at end of file
include/tray/platform/linux.h
View file @
268a2ccc
#include <gtk/gtk.h>
#include <libappindicator/app-indicator.h>
#include <liba
yatana-a
ppindicator/app-indicator.h>
#define TRAY_APPINDICATOR_ID "tray-id"
...
...
@@ -38,7 +38,7 @@ static GtkMenuShell *_tray_menu(struct tray_menu *m) {
return
menu
;
}
static
int
tray_init
(
struct
tray
*
tray
)
{
int
tray_init
(
struct
tray
*
tray
)
{
if
(
gtk_init_check
(
0
,
NULL
)
==
FALSE
)
{
return
-
1
;
}
...
...
@@ -49,16 +49,16 @@ static int tray_init(struct tray *tray) {
return
0
;
}
static
int
tray_loop
(
int
blocking
)
{
int
tray_loop
(
int
blocking
)
{
gtk_main_iteration_do
(
blocking
);
return
loop_result
;
}
static
void
tray_update
(
struct
tray
*
tray
)
{
void
tray_update
(
struct
tray
*
tray
)
{
app_indicator_set_icon
(
indicator
,
tray
->
icon
);
// GTK is all about reference counting, so previous menu should be destroyed
// here
app_indicator_set_menu
(
indicator
,
GTK_MENU
(
_tray_menu
(
tray
->
menu
)));
}
static
void
tray_exit
()
{
loop_result
=
-
1
;
}
\ No newline at end of file
void
tray_exit
()
{
loop_result
=
-
1
;
}
\ No newline at end of file
include/tray/platform/tray_impl.h
View file @
268a2ccc
#include "tray/tray_raw.h"
#if defined(
TRAY_APPINDICATOR
)
#if defined(
__linux__
)
#include "linux.h"
#elif defined(T
RAY_APPKIT
)
#elif defined(T
ARGET_OS_MAC
)
#include "macos.h"
#elif defined(_WIN32)
#include "windows.h"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment