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
12e79be0
Commit
12e79be0
authored
Jan 08, 2017
by
Serge A. Zaitsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed formatting
parent
fad5f0d8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
20 deletions
+13
-20
example.c
example.c
+2
-4
tray.h
tray.h
+11
-16
No files found.
example.c
View file @
12e79be0
...
...
@@ -21,11 +21,9 @@ static void quit_cb(struct tray_menu *item) {
static
struct
tray
tray
=
{
.
icon
=
"indicator-messages-new"
,
.
menu
=
(
struct
tray_menu
[]){
{
NULL
,
"Hello"
,
0
,
hello_cb
,
NULL
},
.
menu
=
(
struct
tray_menu
[]){{
NULL
,
"Hello"
,
0
,
hello_cb
,
NULL
},
{
NULL
,
"Quit"
,
0
,
quit_cb
,
NULL
},
{
NULL
,
NULL
,
0
,
NULL
,
NULL
}
},
{
NULL
,
NULL
,
0
,
NULL
,
NULL
}},
};
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
tray.h
View file @
12e79be0
...
...
@@ -31,7 +31,7 @@ static AppIndicator *indicator = NULL;
static
int
loop_result
=
0
;
static
void
_tray_menu_cb
(
GtkMenuItem
*
item
,
gpointer
data
)
{
struct
tray_menu
*
m
=
(
struct
tray_menu
*
)
data
;
struct
tray_menu
*
m
=
(
struct
tray_menu
*
)
data
;
m
->
cb
(
m
);
}
...
...
@@ -67,9 +67,7 @@ static void tray_update(struct tray *tray) {
app_indicator_set_menu
(
indicator
,
GTK_MENU
(
gtk_menu
));
}
static
void
tray_exit
()
{
loop_result
=
-
1
;
}
static
void
tray_exit
()
{
loop_result
=
-
1
;
}
#elif defined(TRAY_APPKIT)
...
...
@@ -80,13 +78,13 @@ static NSStatusBar *statusBar;
static
id
statusItem
;
static
id
statusBarButton
;
@interface
Tray
:
NSObject
<
NSApplicationDelegate
>
-
(
void
)
menuCallback
:
(
id
)
sender
;
@interface
Tray
:
NSObject
<
NSApplicationDelegate
>
-
(
void
)
menuCallback
:
(
id
)
sender
;
@end
@implementation
Tray
-
(
void
)
menuCallback
:
(
id
)
sender
{
struct
tray_menu
*
m
=
(
struct
tray_menu
*
)
[[
sender
representedObject
]
pointerValue
];
-
(
void
)
menuCallback
:(
id
)
sender
{
struct
tray_menu
*
m
=
(
struct
tray_menu
*
)
[[
sender
representedObject
]
pointerValue
];
m
->
cb
(
m
);
}
@end
...
...
@@ -96,7 +94,7 @@ static int tray_init(struct tray *tray) {
[
NSApplication
sharedApplication
];
Tray
*
trayDelegate
=
[
Tray
new
];
[
NSApp
setDelegate
:
trayDelegate
];
[
NSApp
setDelegate
:
trayDelegate
];
statusBar
=
[
NSStatusBar
systemStatusBar
];
statusItem
=
[
statusBar
statusItemWithLength
:
NSVariableStatusItemLength
];
...
...
@@ -131,12 +129,11 @@ static void tray_update(struct tray *tray) {
for
(
struct
tray_menu
*
m
=
tray
->
menu
;
m
!=
NULL
&&
m
->
text
!=
NULL
;
m
++
)
{
NSMenuItem
*
menuItem
=
[
NSMenuItem
alloc
];
[
menuItem
autorelease
];
[
menuItem
initWithTitle
:
[
NSString
stringWithUTF8String
:
m
->
text
]
[
menuItem
initWithTitle
:[
NSString
stringWithUTF8String
:
m
->
text
]
action
:
@selector
(
menuCallback
:
)
keyEquivalent
:
@""
];
[
menuItem
setEnabled
:
YES
];
[
menuItem
setRepresentedObject
:
[
NSValue
valueWithPointer
:
m
]];
[
menuItem
setRepresentedObject
:[
NSValue
valueWithPointer
:
m
]];
[
menu
addItem
:
menuItem
];
...
...
@@ -146,9 +143,7 @@ static void tray_update(struct tray *tray) {
[
statusItem
setMenu
:
menu
];
}
static
void
tray_exit
()
{
[
NSApp
terminate
:
NSApp
];
}
static
void
tray_exit
()
{
[
NSApp
terminate
:
NSApp
];
}
#elif defined(TRAY_WINAPI)
#else
...
...
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