From: TimePath Date: Wed, 17 Feb 2016 02:36:12 +0000 (+1100) Subject: Wrap GtkTreeView X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d2c3bcaf3b069b12884386c62a14fe56ce1bfe8f;p=xonotic%2Fnetradiant.git Wrap GtkTreeView --- diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 0ab8e955..08f4b1c7 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -94,4 +94,7 @@ namespace ui { 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))) + { } + } diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index 17a76410..fb726994 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -9,6 +9,8 @@ using ui_evkey = struct _GdkEventKey; 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; @@ -88,7 +90,7 @@ namespace ui { extern Widget root; -#define WIDGET(name, impl, methods) \ +#define WRAP(name, impl, methods) \ class name : public Widget, public Convertible { \ public: \ explicit name(impl *h = nullptr) : Widget(reinterpret_cast(h)) {} \ @@ -96,7 +98,7 @@ namespace ui { }; \ 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); @@ -109,24 +111,32 @@ namespace ui { 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 diff --git a/radiant/build.cpp b/radiant/build.cpp index 4ba1e913..7294df5c 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -879,7 +879,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi { 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(); @@ -916,7 +916,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi { 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(); diff --git a/radiant/commands.cpp b/radiant/commands.cpp index 7cf2d344..eb3afaa4 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -406,7 +406,7 @@ void DoCommandListDlg(){ { 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 diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 087ea62b..7eb95ff1 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -1419,7 +1419,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ { 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 ); diff --git a/radiant/feedback.cpp b/radiant/feedback.cpp index 0c7632c9..e823341b 100644 --- a/radiant/feedback.cpp +++ b/radiant/feedback.cpp @@ -307,7 +307,7 @@ ui::Window CDbgDlg::BuildDialog(){ { 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 ); { diff --git a/radiant/map.cpp b/radiant/map.cpp index 0de6707f..ea6fd8a0 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -846,7 +846,7 @@ void DoMapInfo(){ { 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 ); { diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index c84538a7..f93f6b45 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -751,7 +751,7 @@ ui::Window PrefsDlg::BuildDialog(){ { 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 ); { diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index ae4b57af..7c8808df 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -2080,7 +2080,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ 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 ); @@ -2108,7 +2108,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ 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 );