update checkbox implementation
This commit is contained in:
@@ -62,13 +62,13 @@ static struct tray tray = {
|
|||||||
.menu =
|
.menu =
|
||||||
(struct tray_menu[]) {
|
(struct tray_menu[]) {
|
||||||
{.text = "Hello", .cb = hello_cb},
|
{.text = "Hello", .cb = hello_cb},
|
||||||
{.text = "Checked", .checked = 1, .cb = toggle_cb},
|
{.text = "Checked", .checked = 1, .checkbox = 1, .cb = toggle_cb},
|
||||||
{.text = "Disabled", .disabled = 1},
|
{.text = "Disabled", .disabled = 1},
|
||||||
{.text = "-"},
|
{.text = "-"},
|
||||||
{.text = "SubMenu",
|
{.text = "SubMenu",
|
||||||
.submenu =
|
.submenu =
|
||||||
(struct tray_menu[]) {
|
(struct tray_menu[]) {
|
||||||
{.text = "FIRST", .checked = 1, .cb = submenu_cb},
|
{.text = "FIRST", .checked = 1, .checkbox = 1, .cb = submenu_cb},
|
||||||
{.text = "SECOND",
|
{.text = "SECOND",
|
||||||
.submenu =
|
.submenu =
|
||||||
(struct tray_menu[]) {
|
(struct tray_menu[]) {
|
||||||
|
|||||||
3
tray.h
3
tray.h
@@ -13,6 +13,7 @@ struct tray_menu {
|
|||||||
const char *text;
|
const char *text;
|
||||||
int disabled;
|
int disabled;
|
||||||
int checked;
|
int checked;
|
||||||
|
int checkbox;
|
||||||
|
|
||||||
void (*cb)(struct tray_menu *);
|
void (*cb)(struct tray_menu *);
|
||||||
void *context;
|
void *context;
|
||||||
@@ -49,7 +50,7 @@ static GtkMenuShell *_tray_menu(struct tray_menu *m) {
|
|||||||
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_menu_item_set_submenu(GTK_MENU_ITEM(item),
|
||||||
GTK_WIDGET(_tray_menu(m->submenu)));
|
GTK_WIDGET(_tray_menu(m->submenu)));
|
||||||
} else if (m->checked) {
|
} else if (m->checkbox) {
|
||||||
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);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user