From: Thomas Debesse Date: Tue, 26 May 2020 14:17:01 +0000 (+0200) Subject: Merge commit 'f79ac495d0735b0002068bd1284bf7918b6f6598' into garux-merge X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=42a317b7459e9f8152eb0cae61fbafa87ef67a72;p=xonotic%2Fnetradiant.git Merge commit 'f79ac495d0735b0002068bd1284bf7918b6f6598' into garux-merge --- 42a317b7459e9f8152eb0cae61fbafa87ef67a72 diff --cc radiant/gtkdlgs.cpp index 476e189f,32ee3f3e..f84d580c --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@@ -462,26 -484,27 +462,26 @@@ void DoAbout() ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); - GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "About NetRadiant", dialog ); + auto window = MainFrame_getWindow().create_modal_dialog_window("About NetRadiant", dialog ); { - GtkVBox* vbox = create_dialog_vbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + auto vbox = create_dialog_vbox( 4, 4 ); + window.add(vbox); { - GtkHBox* hbox = create_dialog_hbox( 4 ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, TRUE, 0 ); + auto hbox = create_dialog_hbox( 4 ); + vbox.pack_start( hbox, FALSE, TRUE, 0 ); { - GtkVBox* vbox2 = create_dialog_vbox( 4 ); - gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), TRUE, FALSE, 0 ); + auto vbox2 = create_dialog_vbox( 4 ); + hbox.pack_start( vbox2, TRUE, FALSE, 0 ); { - auto frame = create_dialog_frame( 0, ui::Shadow::IN ); - vbox2.pack_start( frame, FALSE, FALSE, 0 ); - //GtkFrame* frame = create_dialog_frame( 0, GTK_SHADOW_IN ); - //gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); ++ //auto frame = create_dialog_frame( 0, ui::Shadow::IN ); ++ //vbox2.pack_start( frame, FALSE, FALSE, 0 ); { - GtkImage* image = new_local_image( "logo.png" ); - gtk_widget_show( GTK_WIDGET( image ) ); - gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( image ), FALSE, FALSE, 0 ); - //gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( image ) ); + auto image = new_local_image( "logo.png" ); + image.show(); - frame.add(image); ++ //frame.add(image); } } } diff --cc radiant/mainframe.cpp index 01399dfb,2f3db714..b7dbcc49 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@@ -2878,21 -2714,28 +2878,28 @@@ void MainFrame::OnSleep() } -GtkWindow* create_splash(){ - GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) ); - gtk_window_set_decorated( window, FALSE ); - gtk_window_set_resizable( window, FALSE ); - gtk_window_set_modal( window, TRUE ); +ui::Window create_splash(){ + auto window = ui::Window( ui::window_type::TOP ); + gtk_window_set_decorated(window, false); + gtk_window_set_resizable(window, false); + gtk_window_set_modal(window, true); gtk_window_set_default_size( window, -1, -1 ); gtk_window_set_position( window, GTK_WIN_POS_CENTER ); - gtk_container_set_border_width( GTK_CONTAINER( window ), 0 ); + gtk_container_set_border_width(window, 0); - GtkImage* image = new_local_image( "splash.png" ); - gtk_widget_show( GTK_WIDGET( image ) ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( image ) ); + auto image = new_local_image( "splash.png" ); + image.show(); + window.add(image); + if( gtk_image_get_storage_type( image ) == GTK_IMAGE_PIXBUF ){ + GdkBitmap* mask; + GdkPixbuf* pix = gtk_image_get_pixbuf( image ); + gdk_pixbuf_render_pixmap_and_mask( pix, NULL, &mask, 255 ); + gtk_widget_shape_combine_mask ( GTK_WIDGET( window ), mask, 0, 0 ); + } + - gtk_widget_set_size_request( GTK_WIDGET( window ), -1, -1 ); - gtk_widget_show( GTK_WIDGET( window ) ); + window.dimensions(-1, -1); + window.show(); return window; } diff --cc radiant/texwindow.cpp index 23174f1c,ef2ae005..6eab79a4 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@@ -2211,19 -2117,20 +2211,20 @@@ ui::Widget TextureBrowser_constructWind TextureBrowser_createTreeViewTree(); - gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tree ), g_TextureBrowser.m_treeViewTree ); - //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tree ), GTK_WIDGET( g_TextureBrowser.m_treeViewTree ) ); ++ //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tree ), g_TextureBrowser.m_treeViewTree ); + gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tree ), GTK_WIDGET( g_TextureBrowser.m_treeViewTree ) ); - gtk_widget_show( GTK_WIDGET( g_TextureBrowser.m_treeViewTree ) ); + g_TextureBrowser.m_treeViewTree.show(); } { // gl_widget scrollbar - GtkWidget* w = gtk_vscrollbar_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,0,1,1,0 ) ) ); - gtk_table_attach( GTK_TABLE( table ), w, 2, 3, 1, 2, GTK_SHRINK, GTK_FILL, 0, 0 ); - gtk_widget_show( w ); + auto w = ui::Widget::from(gtk_vscrollbar_new( ui::Adjustment( 0,0,0,1,1,0 ) )); + table.attach(w, {2, 3, 1, 2}, {GTK_SHRINK, GTK_FILL}); + w.show(); g_TextureBrowser.m_texture_scroll = w; - GtkAdjustment *vadjustment = gtk_range_get_adjustment( GTK_RANGE( g_TextureBrowser.m_texture_scroll ) ); - g_signal_connect( G_OBJECT( vadjustment ), "value_changed", G_CALLBACK( TextureBrowser_verticalScroll ), &g_TextureBrowser ); + auto vadjustment = ui::Adjustment::from(gtk_range_get_adjustment( GTK_RANGE( g_TextureBrowser.m_texture_scroll ) )); + vadjustment.connect( "value_changed", G_CALLBACK( TextureBrowser_verticalScroll ), &g_TextureBrowser ); - widget_set_visible( g_TextureBrowser.m_texture_scroll, g_TextureBrowser.m_showTextureScrollbar ); + g_TextureBrowser.m_texture_scroll.visible(g_TextureBrowser.m_showTextureScrollbar); } { // gl_widget g_TextureBrowser.m_gl_widget = glwidget_new( FALSE ); @@@ -2255,18 -2162,32 +2256,22 @@@ TextureBrowser_buildTagList(); } { // tag menu bar - GtkWidget* menu_tags = gtk_menu_new(); + auto menu_tags = ui::Menu(ui::New); + gtk_menu_set_title( GTK_MENU( menu_tags ), "Tags" ); - //GtkWidget* tags_item = (GtkWidget*) - TextureBrowser_constructTagsMenu( GTK_MENU( menu_tags ) ); - //gtk_menu_item_set_submenu( GTK_MENU_ITEM( tags_item ), menu_tags ); - //gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), tags_item ); - - GtkButton* button = GTK_BUTTON( gtk_button_new() ); - //button_set_icon( button, "texbro_tags.png" ); - GtkWidget *label = gtk_label_new (">t"); - gtk_container_add (GTK_CONTAINER (button), label); - gtk_widget_show (label); - - gtk_widget_show( GTK_WIDGET( button ) ); - gtk_button_set_relief( button, GTK_RELIEF_NONE ); - gtk_widget_set_size_request( GTK_WIDGET( button ), 22, 22 ); - GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_FOCUS ); - GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_DEFAULT ); - gtk_toolbar_append_element( toolbar, GTK_TOOLBAR_CHILD_WIDGET, GTK_WIDGET( button ), "", "Tags", "", 0, 0, 0 ); - g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( Popup_View_Menu ), menu_tags ); + // auto tags_item = TextureBrowser_constructTagsMenu( menu_tags ); + TextureBrowser_constructTagsMenu( menu_tags ); + // gtk_menu_item_set_submenu( GTK_MENU_ITEM( tags_item ), menu_tags ); + // gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tags_item ); + + auto button = toolbar_append_button( toolbar, "Tags", "texbro_tags.png" ); + button.dimensions( 22, 22 ); + button.connect( "clicked", G_CALLBACK( Popup_View_Menu ), menu_tags ); + + //to show detached menu over floating tex bro and main wnd... + gtk_menu_attach_to_widget( GTK_MENU( menu_tags ), GTK_WIDGET( button ), NULL ); } { // Tag TreeView - g_TextureBrowser.m_scr_win_tags = gtk_scrolled_window_new( NULL, NULL ); + g_TextureBrowser.m_scr_win_tags = ui::ScrolledWindow(ui::New); gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tags ), 0 ); // vertical only scrolling for treeview @@@ -2274,11 -2195,12 +2279,12 @@@ TextureBrowser_createTreeViewTags(); - GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ) ); + auto selection = gtk_tree_view_get_selection(g_TextureBrowser.m_treeViewTags ); gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE ); - gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tags ), g_TextureBrowser.m_treeViewTags ); - //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tags ), GTK_WIDGET( g_TextureBrowser.m_treeViewTags ) ); ++ //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tags ), g_TextureBrowser.m_treeViewTags ); + gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tags ), GTK_WIDGET( g_TextureBrowser.m_treeViewTags ) ); - gtk_widget_show( GTK_WIDGET( g_TextureBrowser.m_treeViewTags ) ); + g_TextureBrowser.m_treeViewTags.show(); } { // Texture/Tag notebook TextureBrowser_constructTagNotebook(); @@@ -2306,90 -2228,92 +2312,92 @@@ gtk_container_set_border_width( GTK_CONTAINER( scrolled_win ), 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); - g_TextureBrowser.m_assigned_store = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ); + g_TextureBrowser.m_assigned_store = ui::ListStore::from(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); - GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_assigned_store ); + auto sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_assigned_store ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(ui::New); - g_TextureBrowser.m_assigned_tree = gtk_tree_view_new_with_model( 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 ); + g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel::from(g_TextureBrowser.m_assigned_store._handle)); + g_TextureBrowser.m_assigned_store.unref(); + g_TextureBrowser.m_assigned_tree.connect( "row-activated", (GCallback) TextureBrowser_removeTags, NULL ); + gtk_tree_view_set_headers_visible(g_TextureBrowser.m_assigned_tree, FALSE ); - GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ) ); + auto selection = gtk_tree_view_get_selection(g_TextureBrowser.m_assigned_tree ); gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE ); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", TAG_COLUMN, NULL ); - gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), column ); - gtk_widget_show( g_TextureBrowser.m_assigned_tree ); + auto column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} ); + gtk_tree_view_append_column(g_TextureBrowser.m_assigned_tree, column ); + g_TextureBrowser.m_assigned_tree.show(); - gtk_widget_show( scrolled_win ); - //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_assigned_tree ) ); - gtk_container_add( GTK_CONTAINER( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_assigned_tree ) ); + scrolled_win.show(); - gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), g_TextureBrowser.m_assigned_tree ); ++ //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), g_TextureBrowser.m_assigned_tree ); ++ gtk_container_add( GTK_CONTAINER( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_available_tree ) ); - gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 0, 1, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); + frame_table.attach(scrolled_win, {0, 1, 1, 3}, {GTK_FILL, GTK_FILL}); } { // available tag list - GtkWidget* scrolled_win = gtk_scrolled_window_new( NULL, NULL ); + ui::Widget scrolled_win = ui::ScrolledWindow(ui::New); gtk_container_set_border_width( GTK_CONTAINER( scrolled_win ), 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); - g_TextureBrowser.m_available_store = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ); - GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_available_store ); + g_TextureBrowser.m_available_store = ui::ListStore::from(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING )); + auto sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_available_store ); gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING ); - GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); + auto renderer = ui::CellRendererText(ui::New); - g_TextureBrowser.m_available_tree = gtk_tree_view_new_with_model( 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 ); + g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel::from(g_TextureBrowser.m_available_store._handle)); + g_TextureBrowser.m_available_store.unref(); + g_TextureBrowser.m_available_tree.connect( "row-activated", (GCallback) TextureBrowser_assignTags, NULL ); + gtk_tree_view_set_headers_visible(g_TextureBrowser.m_available_tree, FALSE ); - GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ) ); + auto selection = gtk_tree_view_get_selection(g_TextureBrowser.m_available_tree ); gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE ); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", TAG_COLUMN, NULL ); - gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), column ); - gtk_widget_show( g_TextureBrowser.m_available_tree ); + auto column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} ); + gtk_tree_view_append_column(g_TextureBrowser.m_available_tree, column ); + g_TextureBrowser.m_available_tree.show(); - gtk_widget_show( scrolled_win ); - //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_available_tree ) ); + scrolled_win.show(); - gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), g_TextureBrowser.m_available_tree ); ++ //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), g_TextureBrowser.m_available_tree ); + gtk_container_add( GTK_CONTAINER( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_available_tree ) ); - gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 2, 3, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); + frame_table.attach(scrolled_win, {2, 3, 1, 3}, {GTK_FILL, GTK_FILL}); } { // tag arrow buttons - GtkWidget* m_btn_left = gtk_button_new(); - GtkWidget* m_btn_right = gtk_button_new(); - GtkWidget* m_arrow_left = gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT ); - GtkWidget* m_arrow_right = gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT ); - gtk_container_add( GTK_CONTAINER( m_btn_left ), m_arrow_left ); - gtk_container_add( GTK_CONTAINER( m_btn_right ), m_arrow_right ); + auto m_btn_left = ui::Button(ui::New); + auto m_btn_right = ui::Button(ui::New); + auto m_arrow_left = ui::Widget::from(gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT )); + auto m_arrow_right = ui::Widget::from(gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT )); + m_btn_left.add(m_arrow_left); + m_btn_right.add(m_arrow_right); // workaround. the size of the tag frame depends of the requested size of the arrow buttons. - gtk_widget_set_size_request( m_arrow_left, -1, 68 ); - gtk_widget_set_size_request( m_arrow_right, -1, 68 ); + m_arrow_left.dimensions(-1, 68); + m_arrow_right.dimensions(-1, 68); - gtk_table_attach( GTK_TABLE( frame_table ), m_btn_left, 1, 2, 1, 2, GTK_SHRINK, GTK_EXPAND, 0, 0 ); - gtk_table_attach( GTK_TABLE( frame_table ), m_btn_right, 1, 2, 2, 3, GTK_SHRINK, GTK_EXPAND, 0, 0 ); + frame_table.attach(m_btn_left, {1, 2, 1, 2}, {GTK_SHRINK, GTK_EXPAND}); + frame_table.attach(m_btn_right, {1, 2, 2, 3}, {GTK_SHRINK, GTK_EXPAND}); - g_signal_connect( G_OBJECT( m_btn_left ), "clicked", G_CALLBACK( TextureBrowser_assignTags ), NULL ); - g_signal_connect( G_OBJECT( m_btn_right ), "clicked", G_CALLBACK( TextureBrowser_removeTags ), NULL ); + m_btn_left.connect( "clicked", G_CALLBACK( TextureBrowser_assignTags ), NULL ); + m_btn_right.connect( "clicked", G_CALLBACK( TextureBrowser_removeTags ), NULL ); - gtk_widget_show( m_btn_left ); - gtk_widget_show( m_btn_right ); - gtk_widget_show( m_arrow_left ); - gtk_widget_show( m_arrow_right ); + m_btn_left.show(); + m_btn_right.show(); + m_arrow_left.show(); + m_arrow_right.show(); } { // tag fram labels - GtkWidget* m_lbl_assigned = gtk_label_new( "Assigned" ); - GtkWidget* m_lbl_unassigned = gtk_label_new( "Available" ); + ui::Widget m_lbl_assigned = ui::Label( "Assigned" ); + ui::Widget m_lbl_unassigned = ui::Label( "Available" ); - gtk_table_attach( GTK_TABLE( frame_table ), m_lbl_assigned, 0, 1, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0 ); - gtk_table_attach( GTK_TABLE( frame_table ), m_lbl_unassigned, 2, 3, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0 ); + frame_table.attach(m_lbl_assigned, {0, 1, 0, 1}, {GTK_EXPAND, GTK_SHRINK}); + frame_table.attach(m_lbl_unassigned, {2, 3, 0, 1}, {GTK_EXPAND, GTK_SHRINK}); - gtk_widget_show( m_lbl_assigned ); - gtk_widget_show( m_lbl_unassigned ); + m_lbl_assigned.show(); + m_lbl_unassigned.show(); } } else { // no tag support, show the texture tree only