Commit a1e7598f authored by Serge A. Zaitsev's avatar Serge A. Zaitsev

moved submenu to the end of the struct to make menu desclaration look better, formatted

parent b677473c
......@@ -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
}
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment