Skip to content

Commit

Permalink
remove trainwrecky code that caused issues now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arisotura committed Oct 26, 2018
1 parent c8d63f2 commit d4d4965
Showing 1 changed file with 0 additions and 80 deletions.
80 changes: 0 additions & 80 deletions src/libui_sdl/libui/unix/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ struct uiMenuItem {
struct menuItemWindow {
uiWindow *w;
gulong signal;

GtkWidget* submenu;
};

enum {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d4d4965

Please sign in to comment.