Add option to remove items from cart

This commit is contained in:
Markus Koch 2019-07-26 21:09:10 +02:00
parent 70fdfa7709
commit a56bb9073a

View File

@ -2,6 +2,8 @@
#include <json-glib/json-glib.h>
typedef struct _YacosCartItemPriv {
GtkWidget *box;
GtkWidget *label_title;
GtkWidget *label_description;
GtkWidget *label_comment;
@ -64,12 +66,21 @@ static void yacos_cart_item_class_init(YacosCartItemClass *klass)
oclass->finalize = yacos_cart_item_finalize;
}
static void yacos_ceart_item_button_delete_cb(GtkWidget *widget, gpointer user_data)
{
YacosCartItem *self = (YacosCartItem *)user_data;
GtkWidget *list_box_row = gtk_widget_get_parent(self->priv.box);
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(list_box_row)), list_box_row);
}
static void yacos_cart_item_init(YacosCartItem *self)
{
GtkBuilder *builder;
GtkWidget *box;
builder = gtk_builder_new_from_resource("/net/notsyncing/yacos/glade/cartItem.glade");
box = GTK_WIDGET(gtk_builder_get_object(builder, "cart_item"));
self->priv.box = GTK_WIDGET(gtk_builder_get_object(builder, "cart_item"));
self->priv.label_id = GTK_WIDGET(gtk_builder_get_object(builder, "label_id"));
self->priv.label_title = GTK_WIDGET(gtk_builder_get_object(builder, "label_title"));
@ -88,7 +99,13 @@ static void yacos_cart_item_init(YacosCartItem *self)
self->priv.api.soup_session_meta = soup_session_new();
gtk_container_add(GTK_CONTAINER(self), box);
g_signal_connect(self->priv.button_delete,
"clicked",
(GCallback) yacos_ceart_item_button_delete_cb,
self);
gtk_container_add(GTK_CONTAINER(self), self->priv.box);
g_object_unref(builder);
}