remove trainwrecky code that caused issues now.

This commit is contained in:
StapleButter 2018-10-26 22:17:27 +02:00
parent c8d63f2be7
commit d4d4965b2f
1 changed files with 0 additions and 80 deletions

View File

@ -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