From d4d4965b2fffc69958685a25a9d9fc0c78b54567 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Fri, 26 Oct 2018 22:17:27 +0200 Subject: [PATCH] remove trainwrecky code that caused issues now. --- src/libui_sdl/libui/unix/menu.c | 80 --------------------------------- 1 file changed, 80 deletions(-) diff --git a/src/libui_sdl/libui/unix/menu.c b/src/libui_sdl/libui/unix/menu.c index b7546ab6..d6414269 100644 --- a/src/libui_sdl/libui/unix/menu.c +++ b/src/libui_sdl/libui/unix/menu.c @@ -30,8 +30,6 @@ struct uiMenuItem { struct menuItemWindow { uiWindow *w; gulong signal; - - GtkWidget* submenu; }; enum { @@ -96,52 +94,9 @@ static void menuItemEnableDisable(uiMenuItem *item, gboolean enabled) { GHashTableIter iter; gpointer widget; - - // extra crummy code for disabling submenus - // TODO: find a better way to do it!!!!!!!!!!!!!!!!!!!!!!!!!! - // noting that: - // * set_sensitive on the menu item does nothing (herpderp) - // * set_sensitive on the submenu disables all the submenu items at once (but then you can't fucking enable them back!!) - // * removing the submenu from the menu item causes it to be destroyed - // * googling gives no results, guess nobody has ever wanted to do this shit or...?????? - // * under Windows we can just disable the menu item and call it good! works exactly as intended! - // * fucking stupid pile of shit - // so until we come up with a better solution, we're just going to do thie following shito - // * remove submenu - // * disable menu item item->disabled = !enabled; g_hash_table_iter_init(&iter, item->windows); - - if (item->popupchild != NULL) - { - gpointer ww; - struct menuItemWindow *w; - - if (enabled) - { - while (g_hash_table_iter_next(&iter, &widget, &ww)) - { - w = (struct menuItemWindow*)ww; - gtk_widget_set_sensitive(GTK_WIDGET(widget), TRUE); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), w->submenu); - g_object_unref(G_OBJECT(w->submenu)); - } - } - else - { - while (g_hash_table_iter_next(&iter, &widget, &ww)) - { - w = (struct menuItemWindow*)ww; - g_object_ref(G_OBJECT(w->submenu)); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), NULL); - gtk_widget_set_sensitive(GTK_WIDGET(widget), FALSE); - } - } - - return; - } - while (g_hash_table_iter_next(&iter, &widget, NULL)) gtk_widget_set_sensitive(GTK_WIDGET(widget), enabled); } @@ -357,8 +312,6 @@ static void appendMenuItem(GtkMenuShell *submenu, uiMenuItem *item, uiWindow *w) gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), c_submenu); for (j = 0; j < m->items->len; j++) appendMenuItem(GTK_MENU_SHELL(c_submenu), g_array_index(m->items, uiMenuItem *, j), w); - - ww->submenu = c_submenu; } } @@ -434,43 +387,10 @@ static void freeMenu(GtkWidget *widget, gpointer data) //(*i)++; } -static void cleanupMenus() -{ - // bit of a hack - // take care of disabled submenus - - uiMenu *m; - guint i; - uiMenuItem *item; - guint j; - - if (menus == NULL) - return; - for (i = 0; i < menus->len; i++) - { - m = g_array_index(menus, uiMenu *, i); - - for (j = 0; j < m->items->len; j++) - { - item = g_array_index(m->items, uiMenuItem *, j); - - if (item->popupchild != NULL && item->disabled) - { - // re-enable this menu item - // connecting its submenu back to it - // so that GTK cleanup doesn't shit itself - menuItemEnableDisable(item, TRUE); - } - } - } -} - void freeMenubar(GtkWidget *mb) { guint i; - cleanupMenus(); - i = 0; gtk_container_foreach(GTK_CONTAINER(mb), freeMenu, &i); // no need to worry about destroying any widgets; destruction of the window they're in will do it for us