#include "main_window.h" struct mainWindow *mainWindow_new(GtkApplication *app) { GtkBuilder *builder; struct mainWindow *mainWindow; builder = gtk_builder_new_from_resource("/net/notsyncing/yacos/glade/mainWindow.glade"); mainWindow = malloc(sizeof(struct mainWindow)); mainWindow->main_window = GTK_WIDGET(gtk_builder_get_object(builder, "main_window")); mainWindow->stack_main = GTK_STACK(gtk_builder_get_object(builder, "stack_main")); mainWindow->page_intro.box = GTK_WIDGET(gtk_builder_get_object(builder, "box_intro")); mainWindow->page_cart.box = GTK_WIDGET(gtk_builder_get_object(builder, "box_cart")); mainWindow->page_cart.list = GTK_LIST_BOX(gtk_builder_get_object(builder, "list_main")); gtk_builder_connect_signals(builder, NULL); g_object_unref(G_OBJECT(builder)); return mainWindow; } void mainWindow_scan_tags(YacosScanner *scanner, struct mainWindow *mainWindow) { // TODO: Currently slow AF! And dirty. Pls rewrite (yea yea I know you won't...) gtk_stack_set_visible_child(mainWindow->stack_main, mainWindow->page_cart.box); GtkWidget *le; GList *l; yacos_tag_id tag_id; GList *stack_children; GList *ll; gboolean found = 0; for (l = yacos_scanner_get_present_tags(scanner); l != NULL; l = l->next) { tag_id = ((struct yacos_scanner_tag*) l->data)->tag_id; stack_children = gtk_container_get_children(GTK_CONTAINER(mainWindow->page_cart.list)); for (ll = stack_children; ll != NULL; ll = ll->next) { if (yacos_cart_item_get_id(((YacosCartItem *) ll->data)) == tag_id) { found = 1; break; } } if (found) continue; le = yacos_cart_item_new(); yacos_cart_item_set_id(YACOS_CART_ITEM(le), tag_id); yacos_cart_item_fetch_meta(YACOS_CART_ITEM(le)); yacos_cart_item_fetch_image(YACOS_CART_ITEM(le)); gtk_list_box_insert(mainWindow->page_cart.list, le, -1); gtk_widget_show(le); } }