void menu_create (GtkWidget *menu, GSList *list, char *target, int check_path) { struct popup *pop; GtkWidget *tempmenu = menu, *subitem = NULL; int childcount = 0; submenu_list = g_slist_prepend (0, menu); while (list) { pop = (struct popup *) list->data; if (!g_ascii_strncasecmp (pop->name, "SUB", 3)) { childcount = 0; tempmenu = menu_quick_sub (pop->cmd, tempmenu, &subitem, XCMENU_DOLIST, -1); } else if (!g_ascii_strncasecmp (pop->name, "TOGGLE", 6)) { childcount++; menu_toggle_item (pop->name + 7, tempmenu, toggle_cb, pop->cmd, cfg_get_bool (pop->cmd)); } else if (!g_ascii_strncasecmp (pop->name, "ENDSUB", 6)) { /* empty sub menu due to no programs in PATH? */ if (check_path && childcount < 1) gtk_widget_destroy (subitem); subitem = NULL; if (tempmenu != menu) tempmenu = menu_quick_endsub (); /* If we get here and tempmenu equals menu that means we havent got any submenus to exit from */ } else if (!g_ascii_strncasecmp (pop->name, "SEP", 3)) { menu_quick_item (0, 0, tempmenu, XCMENU_SHADED, 0, 0); } else { if (!check_path || pop->cmd[0] != '!') { menu_quick_item (pop->cmd, pop->name, tempmenu, 0, target, 0); /* check if the program is in path, if not, leave it out! */ } else if (is_in_path (pop->cmd)) { childcount++; menu_quick_item (pop->cmd, pop->name, tempmenu, 0, target, 0); } } list = list->next; } /* Let's clean up the linked list from mem */ while (submenu_list) submenu_list = g_slist_remove (submenu_list, submenu_list->data); }
static GtkWidget * menu_add_toggle(GtkWidget *menu, menu_entry * me) { GtkWidget *item = NULL; char *path = me->path + me->root_offset; if (path[0] != 0) menu = menu_find_path(menu, path); if (menu) { item = menu_toggle_item(me->label, menu, menu_toggle_cb, me, me->state); menu_reorder(GTK_MENU(menu), item, me->pos); } return item; }
static void blink_item (unsigned int *setting, GtkWidget *menu, char *label) { menu_toggle_item (label, menu, tray_toggle_cb, setting, *setting); }