From: Garux Date: Tue, 1 Aug 2017 11:06:00 +0000 (+0300) Subject: Radiant: X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2de8ee725b2a6e54e21d5e217ae453ee115b913a;p=xonotic%2Fnetradiant.git Radiant: misc... * fix of 2.24 related: minimize floating window = whole app minimizes + can't restore * fix of 2.24 related: glwidgets inside floating windows were not shown after hide/show of parent widgets * tex bro: menubar = toolbar --- diff --git a/libs/gtkutil/widget.h b/libs/gtkutil/widget.h index ceb92409..f4bc3267 100644 --- a/libs/gtkutil/widget.h +++ b/libs/gtkutil/widget.h @@ -28,8 +28,20 @@ #include "warnings.h" #include "debugging/debugging.h" -inline void widget_set_visible( GtkWidget* widget, bool shown ){ - if ( shown ) { +inline bool widget_is_visible( GtkWidget* widget ){ + return GTK_WIDGET_VISIBLE( widget ) != FALSE; +} + +inline void widget_set_visible( GtkWidget* widget, bool show ){ + if ( show ) { + /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ + GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( widget ), "glwidget" ) ); + if ( glwidget ){ + //if ( widget_is_visible( glwidget ) ) + //globalOutputStream() << "glwidget have been already visible :0\n"; /* is not hidden aswell, according to this */ + gtk_widget_hide( glwidget ); + gtk_widget_show( glwidget ); + } gtk_widget_show( widget ); } else @@ -38,9 +50,6 @@ inline void widget_set_visible( GtkWidget* widget, bool shown ){ } } -inline bool widget_is_visible( GtkWidget* widget ){ - return GTK_WIDGET_VISIBLE( widget ) != FALSE; -} inline void widget_toggle_visible( GtkWidget* widget ){ widget_set_visible( widget, !widget_is_visible( widget ) ); diff --git a/libs/gtkutil/window.cpp b/libs/gtkutil/window.cpp index 48b174b3..74b724fd 100644 --- a/libs/gtkutil/window.cpp +++ b/libs/gtkutil/window.cpp @@ -29,12 +29,18 @@ inline void CHECK_RESTORE( GtkWidget* w ){ if ( gpointer_to_int( g_object_get_data( G_OBJECT( w ), "was_mapped" ) ) != 0 ) { gtk_widget_show( w ); + /* workaround for gtk 2.24 issue: not displayed glwidget after min/restore */ + GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( w ), "glwidget" ) ); + if ( glwidget ){ + gtk_widget_hide( glwidget ); + gtk_widget_show( glwidget ); + } } } inline void CHECK_MINIMIZE( GtkWidget* w ){ g_object_set_data( G_OBJECT( w ), "was_mapped", gint_to_pointer( GTK_WIDGET_VISIBLE( w ) ) ); - gtk_widget_hide( w ); + //gtk_widget_hide( w ); //fix for gtk 2.24 + the whole scheme isn't needed with gtk 2.16, 2.24; they do it all alone } static gboolean main_window_iconified( GtkWidget* widget, GdkEventWindowState* event, gpointer data ){ @@ -90,6 +96,23 @@ GtkWindow* create_floating_window( const char* title, GtkWindow* parent ){ connect_floating_window_destroy_present( window, parent ); g_object_set_data( G_OBJECT( window ), "floating_handler", gint_to_pointer( connect_floating( parent, window ) ) ); g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy_disconnect_floating ), parent ); +/* + //gtk_window_set_type_hint (window,GDK_WINDOW_TYPE_HINT_UTILITY); + //gtk_window_set_type_hint (window,GDK_WINDOW_TYPE_HINT_DIALOG); + gtk_window_set_keep_above ( window, TRUE ); + GtkWidget* widget = GTK_WIDGET( window ); + gtk_widget_realize ( widget ); + GdkWindow* gdk_window = gtk_widget_get_window( widget ); + //gdk_window_set_decorations ( gdk_window, (GdkWMDecoration)(GDK_DECOR_BORDER|GDK_DECOR_RESIZEH|GDK_DECOR_TITLE|GDK_DECOR_MENU|GDK_DECOR_MINIMIZE|GDK_DECOR_MAXIMIZE) ); + //gdk_window_set_functions ( gdk_window, (GdkWMFunction)( GDK_FUNC_RESIZE|GDK_FUNC_MOVE|GDK_FUNC_MINIMIZE|GDK_FUNC_MAXIMIZE|GDK_FUNC_CLOSE ) ); + //gdk_window_set_decorations ( gdk_window, (GdkWMDecoration)( GDK_DECOR_ALL ) ); + //gdk_window_set_functions ( gdk_window, (GdkWMFunction)( GDK_FUNC_ALL ) ); + //gdk_window_set_type_hint ( gdk_window, GDK_WINDOW_TYPE_HINT_DIALOG ); + //gdk_window_set_type_hint ( gdk_window, GDK_WINDOW_TYPE_HINT_UTILITY ); + //gdk_window_set_type_hint ( gdk_window, GDK_WINDOW_TYPE_HINT_NORMAL ); + gdk_window_set_skip_taskbar_hint ( gdk_window, TRUE ); + gdk_window_set_skip_pager_hint ( gdk_window, TRUE ); +*/ } return window; diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index 2e717d12..dc94603b 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -61,6 +61,14 @@ void Create( GtkWindow* parent ); void Show(){ // workaround for strange gtk behaviour - modifying the contents of a window while it is not visible causes the window position to change without sending a configure_event m_position_tracker.sync( m_window ); + /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ + GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( m_window ), "glwidget" ) ); + if ( glwidget ){ + //if ( widget_is_visible( glwidget ) ) + //globalOutputStream() << "glwidget have been already visible :0\n"; /* is not hidden aswell, according to this */ + gtk_widget_hide( glwidget ); + gtk_widget_show( glwidget ); + } gtk_widget_show( GTK_WIDGET( m_window ) ); } void Hide(){ diff --git a/radiant/main.cpp b/radiant/main.cpp index 2e7c93b9..3e797f2d 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -573,6 +573,7 @@ int main( int argc, char* argv[] ){ #endif gtk_disable_setlocale(); + gtk_init( &argc, &argv ); // redirect Gtk warnings to the console diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 172c1439..147d1a65 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -2918,6 +2918,8 @@ void MainFrame::Create(){ gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); } CamWnd_setParent( *m_pCamWnd, window ); + /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ + g_object_set_data( G_OBJECT( window ), "glwidget", CamWnd_getWidget( *m_pCamWnd ) ); g_floating_windows.push_back( GTK_WIDGET( window ) ); } @@ -2937,6 +2939,8 @@ void MainFrame::Create(){ gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); } XY_Top_Shown_Construct( window ); + /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ + g_object_set_data( G_OBJECT( window ), "glwidget", m_pXYWnd->GetWidget() ); g_floating_windows.push_back( GTK_WIDGET( window ) ); } @@ -2956,6 +2960,8 @@ void MainFrame::Create(){ } XZ_Front_Shown_Construct( window ); + /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ + g_object_set_data( G_OBJECT( window ), "glwidget", m_pXZWnd->GetWidget() ); g_floating_windows.push_back( GTK_WIDGET( window ) ); } @@ -2975,6 +2981,8 @@ void MainFrame::Create(){ } YZ_Side_Shown_Construct( window ); + /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ + g_object_set_data( G_OBJECT( window ), "glwidget", m_pYZWnd->GetWidget() ); g_floating_windows.push_back( GTK_WIDGET( window ) ); } @@ -2982,6 +2990,9 @@ void MainFrame::Create(){ { GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) ); g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() ); + /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ + g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() ); + } GroupDialog_show(); @@ -3015,6 +3026,8 @@ void MainFrame::Create(){ { GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( window ) ); g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() ); + /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ + g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() ); } } diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 2b685f52..cf1b6589 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -646,7 +646,7 @@ public: void realise(){ m_realiseCallbacks(); /* texturebrowser tree update on vfs restart */ - TextureBrowser_constructTreeStore(); +// TextureBrowser_constructTreeStore(); } void unrealise(){ } @@ -1764,6 +1764,10 @@ GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){ return textures_menu_item; } +void Popup_View_Menu( GtkWidget *widget, GtkMenu *menu ){ + gtk_menu_popup( menu, NULL, NULL, NULL, NULL, 1, gtk_get_current_event_time() ); +} + GtkMenuItem* TextureBrowser_constructToolsMenu( GtkMenu* menu ){ GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "_Tools" ); @@ -2071,25 +2075,54 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ GtkWidget* table = gtk_table_new( 3, 3, FALSE ); GtkWidget* frame_table = NULL; GtkWidget* vbox = gtk_vbox_new( FALSE, 0 ); - gtk_table_attach( GTK_TABLE( table ), vbox, 0, 1, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); + gtk_table_attach( GTK_TABLE( table ), vbox, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0 ); gtk_widget_show( vbox ); - GtkWidget* menu_bar; + //GtkWidget* menu_bar; + GtkToolbar* toolbar; { // menu bar - menu_bar = gtk_menu_bar_new(); + //menu_bar = gtk_menu_bar_new(); GtkWidget* menu_view = gtk_menu_new(); - GtkWidget* view_item = (GtkWidget*)TextureBrowser_constructViewMenu( GTK_MENU( menu_view ) ); - gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view ); - gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), view_item ); + //GtkWidget* view_item = (GtkWidget*) + TextureBrowser_constructViewMenu( GTK_MENU( menu_view ) ); + //gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view ); + //gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), view_item ); + + + toolbar = GTK_TOOLBAR( gtk_toolbar_new() ); + //gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( toolbar ), 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0 ); + gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( toolbar ), FALSE, FALSE, 0 ); + + //view menu button + GtkButton* button = GTK_BUTTON( gtk_button_new() ); + button_set_icon( button, "texbro_view.png" ); + 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 ), "", "View", "", 0, 0, 0 ); + g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( Popup_View_Menu ), menu_view ); + + + button = toolbar_append_button( toolbar, "Find / Replace...", "texbro_gtk-find-and-replace.png", "FindReplaceTextures" ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 22, 22 ); + + + button = toolbar_append_button( toolbar, "Flush & Reload Shaders", "texbro_refresh.png", "RefreshShaders" ); + gtk_widget_set_size_request( GTK_WIDGET( button ), 22, 22 ); + gtk_widget_show( GTK_WIDGET( toolbar ) ); + +/* GtkWidget* menu_tools = gtk_menu_new(); GtkWidget* tools_item = (GtkWidget*)TextureBrowser_constructToolsMenu( GTK_MENU( menu_tools ) ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( tools_item ), menu_tools ); gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), tools_item ); - - gtk_table_attach( GTK_TABLE( table ), menu_bar, 0, 3, 0, 1, GTK_FILL, GTK_SHRINK, 0, 0 ); - gtk_widget_show( menu_bar ); +*/ + //gtk_table_attach( GTK_TABLE( table ), menu_bar, 0, 3, 0, 1, GTK_FILL, GTK_SHRINK, 0, 0 ); + //gtk_widget_show( menu_bar ); } { // Texture TreeView g_TextureBrowser.m_scr_win_tree = gtk_scrolled_window_new( NULL, NULL ); @@ -2147,9 +2180,24 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ } { // tag menu bar GtkWidget* menu_tags = gtk_menu_new(); - 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 ); + //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 ); } { // Tag TreeView g_TextureBrowser.m_scr_win_tags = gtk_scrolled_window_new( NULL, NULL ); @@ -2497,6 +2545,8 @@ void RefreshShaders(){ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" ); GlobalShaderSystem().refresh(); + /* texturebrowser tree update on vfs restart */ + TextureBrowser_constructTreeStore(); UpdateAllWindows(); TextureBrowser_ShowDirectory( GlobalTextureBrowser(), dirName ); @@ -2505,6 +2555,8 @@ void RefreshShaders(){ else{ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" ); GlobalShaderSystem().refresh(); + /* texturebrowser tree update on vfs restart */ + TextureBrowser_constructTreeStore(); UpdateAllWindows(); } @@ -2762,3 +2814,7 @@ void TextureBrowser_Destroy(){ Textures_setModeChangedNotify( Callback() ); } + +GtkWidget* TextureBrowser_getGLWidget(){ + return GlobalTextureBrowser().m_gl_widget; +} diff --git a/radiant/texwindow.h b/radiant/texwindow.h index 3a872014..d62c772a 100644 --- a/radiant/texwindow.h +++ b/radiant/texwindow.h @@ -59,4 +59,6 @@ void TextureBrowser_setBackgroundColour( TextureBrowser& textureBrowser, const V void TextureBrowser_addActiveShadersChangedCallback( const SignalHandler& handler ); void TextureBrowser_addShadersRealiseCallback( const SignalHandler& handler ); +GtkWidget* TextureBrowser_getGLWidget(); + #endif diff --git a/setup/data/tools/bitmaps/texbro_gtk-find-and-replace.png b/setup/data/tools/bitmaps/texbro_gtk-find-and-replace.png new file mode 100644 index 00000000..fca34f52 Binary files /dev/null and b/setup/data/tools/bitmaps/texbro_gtk-find-and-replace.png differ diff --git a/setup/data/tools/bitmaps/texbro_refresh.png b/setup/data/tools/bitmaps/texbro_refresh.png new file mode 100644 index 00000000..ed2419ab Binary files /dev/null and b/setup/data/tools/bitmaps/texbro_refresh.png differ diff --git a/setup/data/tools/bitmaps/texbro_view.png b/setup/data/tools/bitmaps/texbro_view.png new file mode 100644 index 00000000..cf2f4ac8 Binary files /dev/null and b/setup/data/tools/bitmaps/texbro_view.png differ