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
33032258
Commit
33032258
authored
Jul 03, 2024
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
portproton
parent
9c080016
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
28 deletions
+21
-28
CMakeLists.txt
CMakeLists.txt
+1
-1
example_pp.cpp
example/example_pp.cpp
+13
-12
linux.h
include/tray/platform/linux.h
+2
-6
tray.h
include/tray/tray.h
+1
-4
tray_raw.h
include/tray/tray_raw.h
+1
-0
tray.cpp
src/tray.cpp
+3
-5
No files found.
CMakeLists.txt
View file @
33032258
...
...
@@ -37,7 +37,7 @@ target_link_libraries(traypp_test PRIVATE tray)
add_custom_command
(
TARGET tray_test
POST_BUILD
COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
_if_different
COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
${
CMAKE_SOURCE_DIR
}
/example/
${
CMAKE_BINARY_DIR
}
/
)
...
...
example/example_pp.cpp
View file @
33032258
...
...
@@ -3,21 +3,23 @@
#include <stdlib.h>
int
main
()
{
trays
::
Menu
m
;
m
.
text_
=
"Open work dir"
;
trays
::
Menu
q
;
q
.
text_
=
"WINEFILE"
;
trays
::
Menu
w
;
w
.
text_
=
"TASKMGR"
;
trays
::
Menu
e
;
e
.
text_
=
"CHANGELOG"
;
// linux: png, svg
std
::
string
icon_name
=
"
icon.pn
g"
;
std
::
string
icon_name
=
"
portproton_tray.sv
g"
;
// absolute path for linux.
auto
icon_path
=
std
::
filesystem
::
current_path
()
/
icon_name
;
#ifdef _WIN32
m
.
on_click_
=
[](
auto
)
{
system
(
"start .
"
);
};
#else
m
.
on_click_
=
[](
auto
)
{
system
(
"open ."
);
};
#endif
q
.
on_click_
=
[](
auto
)
{
system
(
"bash -c pw_tray_winefile &"
);
};
w
.
on_click_
=
[](
auto
)
{
system
(
"bash -c pw_tray_taskmgr &
"
);
};
e
.
on_click_
=
[](
auto
)
{
system
(
"bash -c open_changelog &"
);
};
trays
::
Tray
t
{
icon_path
.
string
(),
{
q
,
w
,
e
}};
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 @
33032258
...
...
@@ -16,18 +16,14 @@ static GtkMenuShell *_tray_menu(struct tray_menu *m) {
GtkMenuShell
*
menu
=
(
GtkMenuShell
*
)
gtk_menu_new
();
for
(;
m
!=
NULL
&&
m
->
text
!=
NULL
;
m
++
)
{
GtkWidget
*
item
;
if
(
strcmp
(
m
->
text
,
"-"
)
==
0
)
{
item
=
gtk_separator_menu_item_new
();
}
else
{
if
(
m
->
submenu
!=
NULL
)
{
item
=
gtk_menu_item_new_with_label
(
m
->
text
);
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
item
),
GTK_WIDGET
(
_tray_menu
(
m
->
submenu
)));
}
else
{
item
=
gtk_check_menu_item_new_with_label
(
m
->
text
);
gtk_check_menu_item_set_active
(
GTK_CHECK_MENU_ITEM
(
item
),
!!
m
->
checked
);
}
gtk_widget_set_sensitive
(
item
,
!
m
->
disabled
);
if
(
m
->
cb
!=
NULL
)
{
g_signal_connect
(
item
,
"activate"
,
G_CALLBACK
(
_tray_menu_cb
),
m
);
}
...
...
include/tray/tray.h
View file @
33032258
...
...
@@ -9,8 +9,6 @@ namespace trays {
class
Menu
{
public
:
std
::
string
text_
;
bool
check_able_
{};
bool
disabled_
{};
std
::
function
<
void
(
Menu
*
self
)
>
on_click_
;
};
class
Tray
{
...
...
@@ -27,4 +25,4 @@ private:
struct
tray
tray_
{};
bool
init_finished_
{};
};
}
// namespace trays
\ No newline at end of file
}
// namespace trays
include/tray/tray_raw.h
View file @
33032258
...
...
@@ -15,6 +15,7 @@ struct tray_menu {
int
disabled
;
int
checked
;
void
(
*
cb
)(
struct
tray_menu
*
);
void
*
context
;
...
...
src/tray.cpp
View file @
33032258
...
...
@@ -6,8 +6,8 @@ trays::Tray::Tray(std::string icon_path, std::vector<Menu> menus)
}
Menu
exit
;
exit
.
on_click_
=
[](
Menu
*
)
{
tray_exit
();
};
exit
.
text_
=
"
exit
"
;
exit
.
on_click_
=
[](
Menu
*
)
{
system
(
"bash -c tray_icon_click_exit"
);
tray_exit
();
};
exit
.
text_
=
"
FORCE EXIT
"
;
add
(
exit
);
tray_
.
icon
=
&
icon_path
[
0
];
...
...
@@ -27,7 +27,7 @@ trays::Tray::Tray(std::string icon_path, std::vector<Menu> menus)
}
void
trays
::
Tray
::
run
()
{
while
(
!
tray_loop
(
1
))
{
printf
(
"Running
\n
"
)
;
;
}
}
void
trays
::
Tray
::
add
(
Menu
menu
)
{
...
...
@@ -37,8 +37,6 @@ void trays::Tray::add(Menu menu) {
auto
ptr
=
std
::
make_unique
<
Menu
>
(
menu
);
tray_menu
me
{};
me
.
context
=
ptr
.
get
();
me
.
checked
=
menu
.
check_able_
;
me
.
disabled
=
menu
.
disabled_
;
me
.
text
=
&
ptr
->
text_
[
0
];
me
.
cb
=
[](
tray_menu
*
mem
)
{
...
...
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