Label::Label(const char *label) : Label(GTK_LABEL(gtk_label_new(label)))
{ }
+ TreeView::TreeView(TreeModel model) : TreeView(GTK_TREE_VIEW(gtk_tree_view_new_with_model(model)))
+ { }
+
}
using ui_label = struct _GtkLabel;
using ui_menuitem = struct _GtkMenuItem;
using ui_modal = struct ModalDialog;
+using ui_treemodel = struct _GtkTreeModel;
+using ui_treeview = struct _GtkTreeView;
using ui_typeinst = struct _GTypeInstance;
using ui_widget = struct _GtkWidget;
using ui_window = struct _GtkWindow;
extern Widget root;
-#define WIDGET(name, impl, methods) \
+#define WRAP(name, impl, methods) \
class name : public Widget, public Convertible<name, impl> { \
public: \
explicit name(impl *h = nullptr) : Widget(reinterpret_cast<ui_widget *>(h)) {} \
}; \
static_assert(sizeof(name) == sizeof(Widget), "object slicing")
- WIDGET(Window, ui_window,
+ WRAP(Window, ui_window,
Window create_dialog_window(const char *title, void func(), void *data, int default_w = -1,
int default_h = -1);
void *extra = nullptr);
);
- WIDGET(Button, ui_button,
+ WRAP(Button, ui_button,
Button(const char *label);
);
- WIDGET(CheckButton, ui_widget,);
+ WRAP(CheckButton, ui_widget,);
- WIDGET(SpinButton, ui_widget,);
+ WRAP(SpinButton, ui_widget,);
- WIDGET(MenuItem, ui_menuitem,);
+ WRAP(MenuItem, ui_menuitem,);
- WIDGET(Label, ui_label,
+ WRAP(Label, ui_label,
Label(const char *label);
);
- WIDGET(Alignment, ui_alignment,
+ WRAP(Alignment, ui_alignment,
Alignment(float xalign, float yalign, float xscale, float yscale);
);
+ WRAP(TreeModel, ui_treemodel, );
+
+ WRAP(TreeView, ui_treeview,
+ TreeView(TreeModel model);
+ );
+
+#undef WRAP
+
}
#endif
{
GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING );
- ui::Widget view = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ));
+ ui::Widget view = ui::TreeView( ui::TreeModel(GTK_TREE_MODEL( store ) ));
gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
{
GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING );
- ui::Widget view = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ));
+ ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) ));
gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
{
GtkListStore* store = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT );
- ui::Widget view = ui::Widget(gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)));
+ ui::Widget view = ui::TreeView(ui::TreeModel(GTK_TREE_MODEL(store)));
dialog.m_list = GTK_TREE_VIEW( view );
gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), false ); // annoying
{
GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING );
- ui::Widget view = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ));
+ ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) ));
gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE );
gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
{
GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING );
- ui::Widget view = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ));
+ ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) ));
gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
{
{
GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING );
- ui::Widget view = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ));
+ ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) ));
gtk_tree_view_set_headers_clickable( GTK_TREE_VIEW( view ), TRUE );
{
{
GtkTreeStore* store = gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER );
- ui::Widget view = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ));
+ ui::Widget view = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( store ) ));
gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
{
GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- g_TextureBrowser.m_assigned_tree = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) ));
+ g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) ));
g_object_unref( G_OBJECT( g_TextureBrowser.m_assigned_store ) );
g_signal_connect( g_TextureBrowser.m_assigned_tree, "row-activated", (GCallback) TextureBrowser_removeTags, NULL );
gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), FALSE );
GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- g_TextureBrowser.m_available_tree = ui::Widget(gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) ));
+ g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) ));
g_object_unref( G_OBJECT( g_TextureBrowser.m_available_store ) );
g_signal_connect( g_TextureBrowser.m_available_tree, "row-activated", (GCallback) TextureBrowser_assignTags, NULL );
gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), FALSE );