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,32 +48,29 @@ static void submenu_cb(struct tray_menu *item) { ...@@ -48,32 +48,29 @@ static void submenu_cb(struct tray_menu *item) {
// Test tray init // Test tray init
static struct tray tray = { static struct tray tray = {
.icon = TRAY_ICON1, .icon = TRAY_ICON1,
.menu = (struct tray_menu[]){ .menu =
{"Hello", 0, 0, NULL, hello_cb, NULL}, (struct tray_menu[]){
{"Checked", 0, 1, NULL, toggle_cb, NULL}, {"Hello", 0, 0, hello_cb, NULL, NULL},
{"Checked", 0, 1, toggle_cb, NULL, NULL},
{"Disabled", 1, 0, NULL, NULL, NULL}, {"Disabled", 1, 0, NULL, NULL, NULL},
{"-", 0, 0, NULL, NULL, NULL}, {"-", 0, 0, NULL, NULL, NULL},
{"Quit", 0, 0, NULL, quit_cb, NULL}, {"Quit", 0, 0, quit_cb, NULL, NULL},
{"SubMenu", 0, 0, {"SubMenu", 0, 0, NULL, NULL,
(struct tray_menu[]){ (struct tray_menu[]){
{"FIRST", 0, 1, NULL, submenu_cb, NULL}, {"FIRST", 0, 1, submenu_cb, NULL, NULL},
{"SECOND", 0, 0, {"SECOND", 0, 0, NULL, NULL,
(struct tray_menu[]){ (struct tray_menu[]){
{"THIRD", 0, 0, {"THIRD", 0, 0, NULL, NULL,
(struct tray_menu[]){{"7", 0, 0, NULL, submenu_cb, NULL}, (struct tray_menu[]){{"7", 0, 0, submenu_cb, NULL, NULL},
{"-", 0, 0, NULL, NULL, NULL}, {"-", 0, 0, NULL, NULL, NULL},
{"8", 0, 0, NULL, submenu_cb, NULL}, {"8", 0, 0, submenu_cb, NULL, NULL},
{NULL, 0, 0, NULL, NULL, NULL}}, {NULL, 0, 0, NULL, NULL, NULL}}},
NULL, NULL}, {"FOUR", 0, 0, NULL, NULL,
{"FOUR", 0, 0, (struct tray_menu[]){{"5", 0, 0, submenu_cb, NULL, NULL},
(struct tray_menu[]){{"5", 0, 0, NULL, submenu_cb, NULL}, {"6", 0, 0, submenu_cb, NULL, NULL},
{"6", 0, 0, NULL, submenu_cb, NULL}, {NULL, 0, 0, NULL, NULL, NULL}}},
{NULL, 0, 0, NULL, NULL, NULL}}, {NULL, 0, 0, NULL, NULL, NULL}}},
NULL, NULL}, {NULL, 0, 0, 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}}, {NULL, 0, 0, NULL, NULL, NULL}},
}; };
......
...@@ -12,10 +12,11 @@ struct tray_menu { ...@@ -12,10 +12,11 @@ struct tray_menu {
char *text; char *text;
int disabled; int disabled;
int checked; int checked;
struct tray_menu *submenu;
void (*cb)(struct tray_menu *); void (*cb)(struct tray_menu *);
void *context; void *context;
struct tray_menu *submenu;
}; };
static void tray_update(struct tray *tray); static void tray_update(struct tray *tray);
...@@ -45,7 +46,8 @@ static GtkMenuShell *_tray_menu(struct tray_menu *m) { ...@@ -45,7 +46,8 @@ static GtkMenuShell *_tray_menu(struct tray_menu *m) {
} else { } else {
if (m->submenu != NULL) { if (m->submenu != NULL) {
item = gtk_menu_item_new_with_label(m->text); 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 { } else {
item = gtk_check_menu_item_new_with_label(m->text); item = gtk_check_menu_item_new_with_label(m->text);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), !!m->checked); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), !!m->checked);
...@@ -180,8 +182,8 @@ static NOTIFYICONDATA nid; ...@@ -180,8 +182,8 @@ static NOTIFYICONDATA nid;
static HWND hwnd; static HWND hwnd;
static HMENU hmenu = NULL; static HMENU hmenu = NULL;
static LRESULT CALLBACK static LRESULT CALLBACK _tray_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam,
_tray_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { LPARAM lparam) {
switch (msg) { switch (msg) {
case WM_CLOSE: case WM_CLOSE:
DestroyWindow(hwnd); 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