-GtkWidget* EntityInspector_constructWindow(GtkWindow* toplevel)
-{
- GtkWidget* vbox = gtk_vbox_new(FALSE, 2);
- gtk_widget_show (vbox);
- gtk_container_set_border_width(GTK_CONTAINER (vbox), 2);
-
- g_signal_connect(G_OBJECT(vbox), "destroy", G_CALLBACK(EntityInspector_destroyWindow), 0);
-
- {
- GtkWidget* split1 = gtk_vpaned_new();
- gtk_box_pack_start(GTK_BOX(vbox), split1, TRUE, TRUE, 0);
- gtk_widget_show (split1);
-
- g_entity_split1 = split1;
-
- {
- GtkWidget* split2 = gtk_vpaned_new();
- gtk_paned_add1 (GTK_PANED (split1), split2);
- gtk_widget_show (split2);
-
- g_entity_split2 = split2;
-
- {
- // class list
- GtkWidget* scr = gtk_scrolled_window_new (0, 0);
- gtk_widget_show (scr);
- gtk_paned_add1 (GTK_PANED (split2), scr);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scr), GTK_SHADOW_IN);
-
- {
- GtkListStore* store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
-
- GtkTreeView* view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)));
- gtk_tree_view_set_enable_search(GTK_TREE_VIEW(view), FALSE);
- gtk_tree_view_set_headers_visible(view, FALSE);
- g_signal_connect(G_OBJECT(view), "button_press_event", G_CALLBACK(EntityClassList_button_press), 0);
- g_signal_connect(G_OBJECT(view), "key_press_event", G_CALLBACK(EntityClassList_keypress), 0);
-
- {
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Key", renderer, "text", 0, 0);
- gtk_tree_view_append_column(view, column);
- }
-
- {
- GtkTreeSelection* selection = gtk_tree_view_get_selection(view);
- g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(EntityClassList_selection_changed), 0);
- }
-
- gtk_widget_show(GTK_WIDGET(view));
-
- gtk_container_add(GTK_CONTAINER(scr), GTK_WIDGET(view));
-
- g_object_unref(G_OBJECT(store));
- g_entityClassList = view;
- g_entlist_store = store;
- }
- }
-
- {
- GtkWidget* scr = gtk_scrolled_window_new (0, 0);
- gtk_widget_show (scr);
- gtk_paned_add2 (GTK_PANED (split2), scr);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scr), GTK_SHADOW_IN);
-
- {
- GtkTextView* text = GTK_TEXT_VIEW(gtk_text_view_new());
- gtk_widget_set_size_request(GTK_WIDGET(text), 0, -1); // allow shrinking
- gtk_text_view_set_wrap_mode(text, GTK_WRAP_WORD);
- gtk_text_view_set_editable(text, FALSE);
- gtk_widget_show(GTK_WIDGET(text));
- gtk_container_add(GTK_CONTAINER(scr), GTK_WIDGET(text));
- g_entityClassComment = text;
- }
- }
- }
-
- {
- GtkWidget* split2 = gtk_vpaned_new();
- gtk_paned_add2 (GTK_PANED (split1), split2);
- gtk_widget_show(split2);
-
- {
- GtkWidget* vbox2 = gtk_vbox_new (FALSE, 2);
- gtk_widget_show (vbox2);
- gtk_paned_pack1(GTK_PANED(split2), vbox2, FALSE, FALSE);
-
- {
- // Spawnflags (4 colums wide max, or window gets too wide.)
- GtkTable* table = GTK_TABLE(gtk_table_new(4, 4, FALSE));
- gtk_box_pack_start (GTK_BOX (vbox2), GTK_WIDGET(table), FALSE, TRUE, 0);
- gtk_widget_show(GTK_WIDGET(table));
-
- g_spawnflagsTable = table;
-
- for (int i = 0; i < MAX_FLAGS; i++)
- {
- GtkCheckButton* check = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(""));
- gtk_widget_ref(GTK_WIDGET(check));
- g_object_set_data(G_OBJECT(check), "handler", gint_to_pointer(g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(SpawnflagCheck_toggled), 0)));
- g_entitySpawnflagsCheck[i] = check;
- }
- }
-
- {
- // key/value list
- GtkWidget* scr = gtk_scrolled_window_new (0, 0);
- gtk_widget_show (scr);
- gtk_box_pack_start (GTK_BOX (vbox2), scr, TRUE, TRUE, 0);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scr), GTK_SHADOW_IN);
-
- {
- GtkListStore* store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
-
- GtkWidget* view = gtk_tree_view_new_with_model(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);
-
- {
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, 0);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- }
-
- {
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 1, 0);
- gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
- }
-
- {
- GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
- g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(EntityProperties_selection_changed), 0);
- }
-
- gtk_widget_show(view);
-
- gtk_container_add(GTK_CONTAINER (scr), view);
-
- g_object_unref(G_OBJECT(store));
-
- g_entprops_store = store;
- }
- }
-
- {
- // key/value entry
- GtkTable* table = GTK_TABLE(gtk_table_new(2, 2, FALSE));
- gtk_widget_show(GTK_WIDGET(table));
- gtk_box_pack_start(GTK_BOX(vbox2), GTK_WIDGET(table), FALSE, TRUE, 0);
- gtk_table_set_row_spacings(table, 3);
- gtk_table_set_col_spacings(table, 5);
-
- {
- GtkEntry* entry = GTK_ENTRY(gtk_entry_new());
- gtk_widget_show(GTK_WIDGET(entry));
- gtk_table_attach(table, GTK_WIDGET(entry), 1, 2, 0, 1,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions)(0), 0, 0);
- gtk_widget_set_events(GTK_WIDGET(entry), GDK_KEY_PRESS_MASK);
- g_signal_connect(G_OBJECT(entry), "key_press_event", G_CALLBACK(EntityEntry_keypress), 0);
- g_entityKeyEntry = entry;
- }
-
- {
- GtkEntry* entry = GTK_ENTRY(gtk_entry_new());
- gtk_widget_show(GTK_WIDGET(entry));
- gtk_table_attach(table, GTK_WIDGET(entry), 1, 2, 1, 2,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions)(0), 0, 0);
- gtk_widget_set_events(GTK_WIDGET(entry), GDK_KEY_PRESS_MASK);
- g_signal_connect(G_OBJECT(entry), "key_press_event", G_CALLBACK(EntityEntry_keypress), 0);
- g_entityValueEntry = entry;
- }
-
- {
- GtkLabel* label = GTK_LABEL(gtk_label_new("Value"));
- gtk_widget_show(GTK_WIDGET(label));
- gtk_table_attach(table, GTK_WIDGET(label), 0, 1, 1, 2,
- (GtkAttachOptions)(GTK_FILL),
- (GtkAttachOptions)(0), 0, 0);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- }
-
- {
- GtkLabel* label = GTK_LABEL(gtk_label_new("Key"));
- gtk_widget_show(GTK_WIDGET(label));
- gtk_table_attach(table, GTK_WIDGET(label), 0, 1, 0, 1,
- (GtkAttachOptions)(GTK_FILL),
- (GtkAttachOptions)(0), 0, 0);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- }
- }
-
- {
- GtkBox* hbox = GTK_BOX(gtk_hbox_new(TRUE, 4));
- gtk_widget_show(GTK_WIDGET(hbox));
- gtk_box_pack_start(GTK_BOX(vbox2), GTK_WIDGET(hbox), FALSE, TRUE, 0);
-
- {
- GtkButton* button = GTK_BUTTON(gtk_button_new_with_label("Clear All"));
- gtk_widget_show(GTK_WIDGET(button));
- g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(EntityInspector_clearAllKeyValues), 0);
- gtk_box_pack_start(hbox, GTK_WIDGET(button), TRUE, TRUE, 0);
- }
- {
- GtkButton* button = GTK_BUTTON(gtk_button_new_with_label("Delete Key"));
- gtk_widget_show(GTK_WIDGET(button));
- g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(EntityInspector_clearKeyValue), 0);
- gtk_box_pack_start(hbox, GTK_WIDGET(button), TRUE, TRUE, 0);
- }
- }
- }
-
- {
- GtkWidget* scr = gtk_scrolled_window_new(0, 0);
- gtk_widget_show(scr);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scr), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-
- GtkWidget* viewport = gtk_viewport_new(0, 0);
- gtk_widget_show(viewport);
- gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
-
- g_attributeBox = GTK_VBOX(gtk_vbox_new(FALSE, 2));
- gtk_widget_show(GTK_WIDGET(g_attributeBox));
-
- gtk_container_add(GTK_CONTAINER(viewport), GTK_WIDGET(g_attributeBox));
- gtk_container_add(GTK_CONTAINER(scr), viewport);
- gtk_paned_pack2(GTK_PANED(split2), scr, FALSE, FALSE);
- }
- }
- }
-
-
- {
- // show the sliders in any case
- if(g_entitysplit2_position > 22)
- {
- gtk_paned_set_position (GTK_PANED(g_entity_split2), g_entitysplit2_position);
- } else {
- g_entitysplit2_position = 22;
- gtk_paned_set_position (GTK_PANED(g_entity_split2), 22);
- }
- if((g_entitysplit1_position - g_entitysplit2_position) > 27)
- {
- gtk_paned_set_position (GTK_PANED(g_entity_split1), g_entitysplit1_position);
- } else {
- gtk_paned_set_position (GTK_PANED(g_entity_split1), g_entitysplit2_position + 27);
- }
- }
-
- g_entityInspector_windowConstructed = true;
- EntityClassList_fill();
-
- typedef FreeCaller1<const Selectable&, EntityInspector_selectionChanged> EntityInspectorSelectionChangedCaller;
- GlobalSelectionSystem().addSelectionChangeCallback(EntityInspectorSelectionChangedCaller());
- GlobalEntityCreator().setKeyValueChangedFunc(EntityInspector_keyValueChanged);
-
- // hack
- gtk_container_set_focus_chain(GTK_CONTAINER(vbox), NULL);
-
- return vbox;
+ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
+ auto vbox = ui::VBox( FALSE, 2 );
+ vbox.show();
+ gtk_container_set_border_width( GTK_CONTAINER( vbox ), 2 );
+
+ vbox.connect( "destroy", G_CALLBACK( EntityInspector_destroyWindow ), 0 );
+
+ {
+ auto split1 = ui::VPaned(ui::New);
+ vbox.pack_start( split1, TRUE, TRUE, 0 );
+ split1.show();
+
+ g_entity_split1 = split1;
+
+ {
+ ui::Widget split2 = ui::VPaned(ui::New);
+ gtk_paned_add1( GTK_PANED( split1 ), split2 );
+ split2.show();
+
+ g_entity_split2 = split2;
+
+ {
+ // class list
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.show();
+ gtk_paned_add1( GTK_PANED( split2 ), scr );
+ gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
+ gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
+
+ {
+ ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ));
+
+ auto view = ui::TreeView( ui::TreeModel::from( store._handle ));
+ gtk_tree_view_set_enable_search(view, FALSE );
+ gtk_tree_view_set_headers_visible( view, FALSE );
+ view.connect( "button_press_event", G_CALLBACK( EntityClassList_button_press ), 0 );
+ view.connect( "key_press_event", G_CALLBACK( EntityClassList_keypress ), 0 );
+
+ {
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "Key", renderer, {{"text", 0}} );
+ gtk_tree_view_append_column( view, column );
+ }
+
+ {
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection( view ));
+ selection.connect( "changed", G_CALLBACK( EntityClassList_selection_changed ), 0 );
+ }
+
+ view.show();
+
+ scr.add(view);
+
+ store.unref();
+ g_entityClassList = view;
+ g_entlist_store = store;
+ }
+ }
+
+ {
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.show();
+ gtk_paned_add2( GTK_PANED( split2 ), scr );
+ gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
+ gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
+
+ {
+ auto text = ui::TextView(ui::New);
+ text.dimensions(0, -1); // allow shrinking
+ gtk_text_view_set_wrap_mode( text, GTK_WRAP_WORD );
+ gtk_text_view_set_editable( text, FALSE );
+ text.show();
+ scr.add(text);
+ g_entityClassComment = text;
+ }
+ }
+ }
+
+ {
+ ui::Widget split2 = ui::VPaned(ui::New);
+ gtk_paned_add2( GTK_PANED( split1 ), split2 );
+ split2.show();
+
+ {
+ auto vbox2 = ui::VBox( FALSE, 2 );
+ vbox2.show();
+ gtk_paned_pack1( GTK_PANED( split2 ), vbox2, FALSE, FALSE );
+
+ {
+ // Spawnflags (4 colums wide max, or window gets too wide.)
+ auto table = ui::Table( 4, 4, FALSE );
+ vbox2.pack_start( table, FALSE, TRUE, 0 );
+ table.show();
+
+ g_spawnflagsTable = table;
+
+ for ( int i = 0; i < MAX_FLAGS; i++ )
+ {
+ auto check = ui::CheckButton( "" );
+ check.ref();
+ g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( check.connect( "toggled", G_CALLBACK( SpawnflagCheck_toggled ), 0 ) ) );
+ g_entitySpawnflagsCheck[i] = check;
+ }
+ }
+
+ {
+ // key/value list
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.show();
+ vbox2.pack_start( scr, TRUE, TRUE, 0 );
+ gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
+ gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
+
+ {
+ ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ));
+
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
+ gtk_tree_view_set_enable_search(view, FALSE );
+ gtk_tree_view_set_headers_visible(view, FALSE );
+
+ {
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
+ gtk_tree_view_append_column(view, column );
+ }
+
+ {
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "", renderer, {{"text", 1}} );
+ gtk_tree_view_append_column(view, column );
+ }
+
+ {
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(view));
+ selection.connect( "changed", G_CALLBACK( EntityProperties_selection_changed ), 0 );
+ }
+
+ view.show();
+
+ scr.add(view);
+
+ store.unref();
+
+ g_entprops_store = store;
+ }
+ }
+
+ {
+ // key/value entry
+ auto table = ui::Table( 2, 2, FALSE );
+ table.show();
+ vbox2.pack_start( table, FALSE, TRUE, 0 );
+ gtk_table_set_row_spacings( table, 3 );
+ gtk_table_set_col_spacings( table, 5 );
+
+ {
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+ gtk_widget_set_events( entry , GDK_KEY_PRESS_MASK );
+ entry.connect( "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 );
+ g_entityKeyEntry = entry;
+ }
+
+ {
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ gtk_widget_set_events( entry , GDK_KEY_PRESS_MASK );
+ entry.connect( "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 );
+ g_entityValueEntry = entry;
+ }
+
+ {
+ auto label = ui::Label( "Value" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
+ }
+
+ {
+ auto label = ui::Label( "Key" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
+ }
+ }
+
+ {
+ auto hbox = ui::HBox( TRUE, 4 );
+ hbox.show();
+ vbox2.pack_start( hbox, FALSE, TRUE, 0 );
+
+ {
+ auto button = ui::Button( "Clear All" );
+ button.show();
+ button.connect( "clicked", G_CALLBACK( EntityInspector_clearAllKeyValues ), 0 );
+ hbox.pack_start( button, TRUE, TRUE, 0 );
+ }
+ {
+ auto button = ui::Button( "Delete Key" );
+ button.show();
+ button.connect( "clicked", G_CALLBACK( EntityInspector_clearKeyValue ), 0 );
+ hbox.pack_start( button, TRUE, TRUE, 0 );
+ }
+ }
+ }
+
+ {
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.show();
+ gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
+
+ auto viewport = ui::Container::from(gtk_viewport_new( 0, 0 ));
+ viewport.show();
+ gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport ), GTK_SHADOW_NONE );
+
+ g_attributeBox = ui::VBox( FALSE, 2 );
+ g_attributeBox.show();
+
+ viewport.add(g_attributeBox);
+ scr.add(viewport);
+ gtk_paned_pack2( GTK_PANED( split2 ), scr, FALSE, FALSE );
+ }
+ }
+ }
+
+
+ {
+ // show the sliders in any case
+ if ( g_entitysplit2_position > 22 ) {
+ gtk_paned_set_position( GTK_PANED( g_entity_split2 ), g_entitysplit2_position );
+ }
+ else {
+ g_entitysplit2_position = 22;
+ gtk_paned_set_position( GTK_PANED( g_entity_split2 ), 22 );
+ }
+ if ( ( g_entitysplit1_position - g_entitysplit2_position ) > 27 ) {
+ gtk_paned_set_position( GTK_PANED( g_entity_split1 ), g_entitysplit1_position );
+ }
+ else {
+ gtk_paned_set_position( GTK_PANED( g_entity_split1 ), g_entitysplit2_position + 27 );
+ }
+ }
+
+ g_entityInspector_windowConstructed = true;
+ EntityClassList_fill();
+
+ typedef FreeCaller<void(const Selectable&), EntityInspector_selectionChanged> EntityInspectorSelectionChangedCaller;
+ GlobalSelectionSystem().addSelectionChangeCallback( EntityInspectorSelectionChangedCaller() );
+ GlobalEntityCreator().setKeyValueChangedFunc( EntityInspector_keyValueChanged );
+
+ // hack
+ gtk_container_set_focus_chain( GTK_CONTAINER( vbox ), NULL );
+
+ return vbox;