]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Radiant:
authorGarux <garux@mail.ru>
Tue, 1 Aug 2017 11:06:00 +0000 (14:06 +0300)
committerGarux <garux@mail.ru>
Tue, 1 Aug 2017 11:06:00 +0000 (14:06 +0300)
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

libs/gtkutil/widget.h
libs/gtkutil/window.cpp
radiant/groupdialog.cpp
radiant/main.cpp
radiant/mainframe.cpp
radiant/texwindow.cpp
radiant/texwindow.h
setup/data/tools/bitmaps/texbro_gtk-find-and-replace.png [new file with mode: 0644]
setup/data/tools/bitmaps/texbro_refresh.png [new file with mode: 0644]
setup/data/tools/bitmaps/texbro_view.png [new file with mode: 0644]

index ceb92409f8bf9c6553fdc193812ca3b41f43ecdf..f4bc32671b80efce8375799b0a910c5bd565fd33 100644 (file)
 #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 ) );
index 48b174b37a6c24baf7b9e17f313cb6987d248aca..74b724fddf613ba805bc37da9484f86cb61f4846 100644 (file)
 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;
index 2e717d121d631d44e8cabdb96b665e749f278f14..dc94603bfa7c9668bec2130e6ec10d15a64bbe67 100644 (file)
@@ -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(){
index 2e7c93b95d3668bca054b4451a50904aee34a857..3e797f2d1e585d57261607c7163c85430562eb1f 100644 (file)
@@ -573,6 +573,7 @@ int main( int argc, char* argv[] ){
 #endif
 
        gtk_disable_setlocale();
+
        gtk_init( &argc, &argv );
 
        // redirect Gtk warnings to the console
index 172c14395eb6e804ebe61897cb5a7e4e8d0b3cb1..147d1a659fbc341bf6c177b4c9d6e3a55903e1f7 100644 (file)
@@ -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() );
                }
        }
 
index 2b685f52a254e9e3ade2ee62e9f5d6d46c81faef..cf1b65896a15518e82e0ff9beaf666ba3008ebdc 100644 (file)
@@ -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;
+}
index 3a872014c2925a410f1a01ff7106ca82cd431317..d62c772a5a13cafc23d1421be2944e50d8b5aee8 100644 (file)
@@ -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 (file)
index 0000000..fca34f5
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 (file)
index 0000000..ed2419a
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 (file)
index 0000000..cf2f4ac
Binary files /dev/null and b/setup/data/tools/bitmaps/texbro_view.png differ