AutoCatGnome/gtkpp/ListItemFactory.cpp
2022-12-31 00:28:31 +03:00

33 lines
1016 B
C++

//
// Created by selim on 13.11.22.
//
#include "ListItemFactory.h"
namespace gtkpp {
void setupListItemCallback(GtkListItemFactory* factory, GtkListItem* list_item, void* data) {
auto self = reinterpret_cast<ListItemFactory*>(data);
auto widget = self->setup();
gtk_list_item_set_child(list_item, widget);
}
void bindListItemCallback(GtkListItemFactory* factory, GtkListItem* list_item, void* data) {
auto self = reinterpret_cast<ListItemFactory*>(data);
auto widget = gtk_list_item_get_child(list_item);
auto item = gtk_list_item_get_item (list_item);
self->bind(widget);
}
ListItemFactory::ListItemFactory() {
_factory = gtk_signal_list_item_factory_new();
g_signal_connect(_factory, "setup", G_CALLBACK(setupListItemCallback), this);
g_signal_connect(_factory, "bind", G_CALLBACK(bindListItemCallback), this);
}
GtkListItemFactory *ListItemFactory::gobj() const {
return _factory;
}
}