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
b03827df
Commit
b03827df
authored
Jul 14, 2024
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
not used
parent
8ff38751
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
2 additions
and
124 deletions
+2
-124
CMakeLists.txt
CMakeLists.txt
+2
-11
example.c
example/example.c
+0
-110
icon.ico
example/icon.ico
+0
-0
icon.png
example/icon.png
+0
-0
tray_raw.h
include/tray/tray_raw.h
+0
-3
No files found.
CMakeLists.txt
View file @
b03827df
...
...
@@ -4,7 +4,7 @@ project(tray VERSION 0.1.0 LANGUAGES C CXX)
include
(
CTest
)
enable_testing
()
add_library
(
tray src/tray.cpp src/raw_tray.c
)
add_library
(
tray src/tray.cpp src/raw_tray.c
)
target_include_directories
(
tray
PUBLIC
include
...
...
@@ -13,7 +13,7 @@ target_include_directories(tray
if
(
UNIX AND NOT APPLE
)
find_package
(
PkgConfig REQUIRED
)
message
(
STATUS
"To install appindicator3[ayatana-appindicator3-0.1], sudo apt install libayatana-appindicator3-dev"
)
pkg_check_modules
(
APPINDICATOR REQUIRED
ayatana-appindicator3-0.1
)
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
}
)
...
...
@@ -27,20 +27,11 @@ elseif(APPLE)
endif
()
if
(
CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME
)
add_executable
(
tray_test example/example.c
)
target_link_libraries
(
tray_test PRIVATE tray
)
add_executable
(
pw_tray example/example_pp.cpp
)
set_target_properties
(
pw_tray PROPERTIES CXX_STANDARD 17
)
target_link_libraries
(
pw_tray PRIVATE tray
)
add_custom_command
(
TARGET tray_test
POST_BUILD
COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
${
CMAKE_SOURCE_DIR
}
/example/
${
CMAKE_BINARY_DIR
}
/
)
endif
()
set
(
CPACK_PROJECT_NAME
${
PROJECT_NAME
}
)
...
...
example/example.c
deleted
100644 → 0
View file @
8ff38751
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined (_WIN32) || defined (_WIN64)
#define TRAY_WINAPI 1
#elif defined (__linux__) || defined (linux) || defined (__linux)
#define TRAY_APPINDICATOR 1
#elif defined (__APPLE__) || defined (__MACH__)
#define TRAY_APPKIT 1
#endif
#include "tray/tray_raw.h"
#if TRAY_APPINDICATOR
#define TRAY_ICON1 "indicator-messages"
#define TRAY_ICON2 "indicator-messages-new"
#elif TRAY_APPKIT
#define TRAY_ICON1 "icon.png"
#define TRAY_ICON2 "icon.png"
#elif TRAY_WINAPI
#define TRAY_ICON1 "icon.ico"
#define TRAY_ICON2 "icon.ico"
#endif
static
struct
tray
tray
;
static
void
toggle_cb
(
struct
tray_menu
*
item
)
{
printf
(
"toggle cb
\n
"
);
item
->
checked
=
!
item
->
checked
;
tray_update
(
&
tray
);
}
static
void
hello_cb
(
struct
tray_menu
*
item
)
{
(
void
)
item
;
printf
(
"hello cb
\n
"
);
if
(
item
->
context
==
NULL
){
item
->
context
=
malloc
(
4
);
memset
(
item
->
context
,
0
,
4
);
}
else
{
int
*
number
=
(
int
*
)
item
->
context
;
(
*
number
)
++
;
printf
(
"hello conut: %d
\n
"
,
*
number
);
}
if
(
strcmp
(
tray
.
icon
,
TRAY_ICON1
)
==
0
)
{
tray
.
icon
=
TRAY_ICON2
;
}
else
{
tray
.
icon
=
TRAY_ICON1
;
}
tray_update
(
&
tray
);
}
static
void
quit_cb
(
struct
tray_menu
*
item
)
{
(
void
)
item
;
printf
(
"quit cb
\n
"
);
tray_exit
();
}
static
void
submenu_cb
(
struct
tray_menu
*
item
)
{
(
void
)
item
;
printf
(
"submenu: clicked on %s
\n
"
,
item
->
text
);
tray_update
(
&
tray
);
}
// Test tray init
static
struct
tray
tray
=
{
.
icon
=
TRAY_ICON1
,
.
menu
=
(
struct
tray_menu
[]){
{.
text
=
"Hello"
,
.
cb
=
hello_cb
},
{.
text
=
"Checked"
,
.
checked
=
1
,
.
cb
=
toggle_cb
},
{.
text
=
"Disabled"
,
.
disabled
=
1
},
{.
text
=
"-"
},
{.
text
=
"SubMenu"
,
.
submenu
=
(
struct
tray_menu
[]){
{.
text
=
"FIRST"
,
.
checked
=
1
,
.
cb
=
submenu_cb
},
{.
text
=
"SECOND"
,
.
submenu
=
(
struct
tray_menu
[]){
{.
text
=
"THIRD"
,
.
submenu
=
(
struct
tray_menu
[]){
{.
text
=
"7"
,
.
cb
=
submenu_cb
},
{.
text
=
"-"
},
{.
text
=
"8"
,
.
cb
=
submenu_cb
},
{.
text
=
NULL
}}},
{.
text
=
"FOUR"
,
.
submenu
=
(
struct
tray_menu
[]){
{.
text
=
"5"
,
.
cb
=
submenu_cb
},
{.
text
=
"6"
,
.
cb
=
submenu_cb
},
{.
text
=
NULL
}}},
{.
text
=
NULL
}}},
{.
text
=
NULL
}}},
{.
text
=
"-"
},
{.
text
=
"Quit"
,
.
cb
=
quit_cb
},
{.
text
=
NULL
}},
};
int
main
()
{
if
(
tray_init
(
&
tray
)
<
0
)
{
printf
(
"failed to create tray
\n
"
);
return
1
;
}
while
(
tray_loop
(
1
)
==
0
)
{
printf
(
"iteration
\n
"
);
}
return
0
;
}
example/icon.ico
deleted
100644 → 0
View file @
8ff38751
361 KB
example/icon.png
deleted
100644 → 0
View file @
8ff38751
361 KB
include/tray/tray_raw.h
View file @
b03827df
...
...
@@ -12,9 +12,6 @@ struct tray {
struct
tray_menu
{
char
*
text
;
int
disabled
;
int
checked
;
void
(
*
cb
)(
struct
tray_menu
*
);
void
*
context
;
...
...
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