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
f71d2ba1
Commit
f71d2ba1
authored
Jan 12, 2017
by
Serge A. Zaitsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added nested menus for macos
parent
f0bdf448
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
22 deletions
+31
-22
tray.h
tray.h
+31
-22
No files found.
tray.h
View file @
f71d2ba1
...
...
@@ -104,10 +104,39 @@ static id statusBarButton;
-
(
void
)
menuCallback
:(
id
)
sender
{
struct
tray_menu
*
m
=
(
struct
tray_menu
*
)[[
sender
representedObject
]
pointerValue
];
m
->
cb
(
m
);
if
(
m
!=
NULL
&&
m
->
cb
!=
NULL
)
{
m
->
cb
(
m
);
}
}
@end
static
NSMenu
*
_tray_menu
(
struct
tray_menu
*
m
)
{
NSMenu
*
menu
=
[
NSMenu
new
];
[
menu
autorelease
];
[
menu
setAutoenablesItems
:
NO
];
for
(;
m
!=
NULL
&&
m
->
text
!=
NULL
;
m
++
)
{
if
(
strcmp
(
m
->
text
,
"-"
)
==
0
)
{
[
menu
addItem
:[
NSMenuItem
separatorItem
]];
}
else
{
NSMenuItem
*
menuItem
=
[
NSMenuItem
alloc
];
[
menuItem
autorelease
];
[
menuItem
initWithTitle
:[
NSString
stringWithUTF8String
:
m
->
text
]
action
:
@selector
(
menuCallback
:
)
keyEquivalent
:
@""
];
[
menuItem
setEnabled
:(
m
->
disabled
?
NO
:
YES
)];
[
menuItem
setState
:(
m
->
checked
?
NSOnState
:
NSOffState
)];
[
menuItem
setRepresentedObject
:[
NSValue
valueWithPointer
:
m
]];
[
menu
addItem
:
menuItem
];
if
(
m
->
submenu
!=
NULL
)
{
[
menu
setSubmenu
:
_tray_menu
(
m
->
submenu
)
forItem
:
menuItem
];
}
}
}
return
menu
;
}
static
int
tray_init
(
struct
tray
*
tray
)
{
pool
=
[
NSAutoreleasePool
new
];
[
NSApplication
sharedApplication
];
...
...
@@ -143,27 +172,7 @@ static void tray_update(struct tray *tray) {
[
statusBarButton
setImage
:[
NSImage
imageNamed
:[
NSString
stringWithUTF8String
:
tray
->
icon
]]];
NSMenu
*
menu
=
[
NSMenu
new
];
[
menu
autorelease
];
[
menu
setAutoenablesItems
:
NO
];
for
(
struct
tray_menu
*
m
=
tray
->
menu
;
m
!=
NULL
&&
m
->
text
!=
NULL
;
m
++
)
{
if
(
strcmp
(
m
->
text
,
"-"
)
==
0
)
{
[
menu
addItem
:[
NSMenuItem
separatorItem
]];
}
else
{
NSMenuItem
*
menuItem
=
[
NSMenuItem
alloc
];
[
menuItem
autorelease
];
[
menuItem
initWithTitle
:[
NSString
stringWithUTF8String
:
m
->
text
]
action
:
@selector
(
menuCallback
:
)
keyEquivalent
:
@""
];
[
menuItem
setEnabled
:(
m
->
disabled
?
NO
:
YES
)];
[
menuItem
setState
:(
m
->
checked
?
NSOnState
:
NSOffState
)];
[
menuItem
setRepresentedObject
:[
NSValue
valueWithPointer
:
m
]];
[
menu
addItem
:
menuItem
];
}
}
[
statusItem
setMenu
:
menu
];
[
statusItem
setMenu
:
_tray_menu
(
tray
->
menu
)];
}
static
void
tray_exit
()
{
[
NSApp
terminate
:
NSApp
];
}
...
...
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