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
a1e7598f
Commit
a1e7598f
authored
Jan 12, 2017
by
Serge A. Zaitsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved submenu to the end of the struct to make menu desclaration look better, formatted
parent
b677473c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
33 deletions
+31
-33
example.c
example.c
+25
-29
tray.h
tray.h
+6
-4
No files found.
example.c
View file @
a1e7598f
...
...
@@ -48,33 +48,30 @@ static void submenu_cb(struct tray_menu *item) {
// Test tray init
static
struct
tray
tray
=
{
.
icon
=
TRAY_ICON1
,
.
menu
=
(
struct
tray_menu
[]){
{
"Hello"
,
0
,
0
,
NULL
,
hello_cb
,
NULL
},
{
"Checked"
,
0
,
1
,
NULL
,
toggle_cb
,
NULL
},
{
"Disabled"
,
1
,
0
,
NULL
,
NULL
,
NULL
},
{
"-"
,
0
,
0
,
NULL
,
NULL
,
NULL
},
{
"Quit"
,
0
,
0
,
NULL
,
quit_cb
,
NULL
},
{
"SubMenu"
,
0
,
0
,
(
struct
tray_menu
[]){
{
"FIRST"
,
0
,
1
,
NULL
,
submenu_cb
,
NULL
},
{
"SECOND"
,
0
,
0
,
(
struct
tray_menu
[]){
{
"THIRD"
,
0
,
0
,
(
struct
tray_menu
[]){{
"7"
,
0
,
0
,
NULL
,
submenu_cb
,
NULL
},
{
"-"
,
0
,
0
,
NULL
,
NULL
,
NULL
},
{
"8"
,
0
,
0
,
NULL
,
submenu_cb
,
NULL
},
{
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
}},
NULL
,
NULL
},
{
"FOUR"
,
0
,
0
,
(
struct
tray_menu
[]){{
"5"
,
0
,
0
,
NULL
,
submenu_cb
,
NULL
},
{
"6"
,
0
,
0
,
NULL
,
submenu_cb
,
NULL
},
{
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
}},
NULL
,
NULL
},
{
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
}},
NULL
,
NULL
},
{
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
}},
NULL
,
NULL
},
{
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
}},
.
menu
=
(
struct
tray_menu
[]){
{
"Hello"
,
0
,
0
,
hello_cb
,
NULL
,
NULL
},
{
"Checked"
,
0
,
1
,
toggle_cb
,
NULL
,
NULL
},
{
"Disabled"
,
1
,
0
,
NULL
,
NULL
,
NULL
},
{
"-"
,
0
,
0
,
NULL
,
NULL
,
NULL
},
{
"Quit"
,
0
,
0
,
quit_cb
,
NULL
,
NULL
},
{
"SubMenu"
,
0
,
0
,
NULL
,
NULL
,
(
struct
tray_menu
[]){
{
"FIRST"
,
0
,
1
,
submenu_cb
,
NULL
,
NULL
},
{
"SECOND"
,
0
,
0
,
NULL
,
NULL
,
(
struct
tray_menu
[]){
{
"THIRD"
,
0
,
0
,
NULL
,
NULL
,
(
struct
tray_menu
[]){{
"7"
,
0
,
0
,
submenu_cb
,
NULL
,
NULL
},
{
"-"
,
0
,
0
,
NULL
,
NULL
,
NULL
},
{
"8"
,
0
,
0
,
submenu_cb
,
NULL
,
NULL
},
{
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
}}},
{
"FOUR"
,
0
,
0
,
NULL
,
NULL
,
(
struct
tray_menu
[]){{
"5"
,
0
,
0
,
submenu_cb
,
NULL
,
NULL
},
{
"6"
,
0
,
0
,
submenu_cb
,
NULL
,
NULL
},
{
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
}}},
{
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
}}},
{
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
}}},
{
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
}},
};
int
main
()
{
...
...
@@ -86,4 +83,4 @@ int main() {
printf
(
"iteration
\n
"
);
}
return
0
;
}
\ No newline at end of file
}
tray.h
View file @
a1e7598f
...
...
@@ -12,10 +12,11 @@ struct tray_menu {
char
*
text
;
int
disabled
;
int
checked
;
struct
tray_menu
*
submenu
;
void
(
*
cb
)(
struct
tray_menu
*
);
void
*
context
;
struct
tray_menu
*
submenu
;
};
static
void
tray_update
(
struct
tray
*
tray
);
...
...
@@ -45,7 +46,8 @@ static GtkMenuShell *_tray_menu(struct tray_menu *m) {
}
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
)));
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
);
...
...
@@ -180,8 +182,8 @@ static NOTIFYICONDATA nid;
static
HWND
hwnd
;
static
HMENU
hmenu
=
NULL
;
static
LRESULT
CALLBACK
_tray_wnd_proc
(
HWND
hwnd
,
UINT
msg
,
WPARAM
wparam
,
LPARAM
lparam
)
{
static
LRESULT
CALLBACK
_tray_wnd_proc
(
HWND
hwnd
,
UINT
msg
,
WPARAM
wparam
,
LPARAM
lparam
)
{
switch
(
msg
)
{
case
WM_CLOSE
:
DestroyWindow
(
hwnd
);
...
...
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