From: Thomas Debesse Date: Sat, 23 Feb 2019 21:40:57 +0000 (+0100) Subject: Merge commit '2de8ee725b2a6e54e21d5e217ae453ee115b913a' into garux-merge X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8e83f5d7ed0e40452949289681c2b89919008405;p=xonotic%2Fnetradiant.git Merge commit '2de8ee725b2a6e54e21d5e217ae453ee115b913a' into garux-merge --- 8e83f5d7ed0e40452949289681c2b89919008405 diff --cc libs/gtkutil/toolbar.cpp index 049d05ec,3ac74f61..8df8802d --- a/libs/gtkutil/toolbar.cpp +++ b/libs/gtkutil/toolbar.cpp @@@ -28,19 -28,31 +28,25 @@@ #include "accelerator.h" #include "button.h" -#include "closure.h" -#include "pointer.h" +#include "image.h" -void toolbar_append( GtkToolbar* toolbar, GtkButton* button, const char* description ){ - gtk_widget_show( GTK_WIDGET( button ) ); - gtk_button_set_relief( button, GTK_RELIEF_NONE ); - 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 ), "", description, "", 0, 0, 0 ); +void toolbar_append( ui::Toolbar toolbar, ui::ToolItem button, const char* description ){ + gtk_widget_show_all(button); + gtk_widget_set_tooltip_text(button, description); + toolbar.add(button); } -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){ - GtkButton* button = GTK_BUTTON( gtk_button_new() ); - button_set_icon( button, icon ); - button_connect_callback( button, callback ); - toolbar_append( toolbar, button, description ); ++ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon ){ ++ auto button = ui::ToolButton::from(gtk_tool_button_new(new_local_image(icon), nullptr)); ++ toolbar_append(toolbar, button, description); + return button; + } + -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){ - GtkToggleButton* button = GTK_TOGGLE_BUTTON( gtk_toggle_button_new() ); - button_set_icon( GTK_BUTTON( button ), icon ); - toggle_button_connect_callback( button, callback ); - toolbar_append( toolbar, GTK_BUTTON( button ), description ); +ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback& callback ){ + auto button = ui::ToolButton::from(gtk_tool_button_new(new_local_image(icon), nullptr)); + button_connect_callback(button, callback); + toolbar_append(toolbar, button, description); return button; } diff --cc libs/gtkutil/toolbar.h index f3481783,6b9e32fb..c995e1be --- a/libs/gtkutil/toolbar.h +++ b/libs/gtkutil/toolbar.h @@@ -28,9 -27,12 +28,10 @@@ class Command; class Toggle; -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ); -GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command ); -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ); -GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle ); ++ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon ); +ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback& callback ); +ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Command& command ); +ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback& callback ); +ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Toggle& toggle ); #endif diff --cc libs/gtkutil/widget.h index 28395b35,f4bc3267..d001fd70 --- a/libs/gtkutil/widget.h +++ b/libs/gtkutil/widget.h @@@ -28,67 -27,116 +28,89 @@@ #include "generic/callback.h" #include "warnings.h" #include "debugging/debugging.h" +#include "property.h" + 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 + { + gtk_widget_hide( widget ); + } + } + +class ToggleItem { + Callback &)> m_exportCallback; + typedef std::list> ImportCallbacks; + ImportCallbacks m_importCallbacks; +public: + ToggleItem(const Callback &)> &exportCallback) : m_exportCallback(exportCallback) + { + } + + void update() + { + for (ImportCallbacks::iterator i = m_importCallbacks.begin(); i != m_importCallbacks.end(); ++i) { + m_exportCallback(*i); + } + } + + void addCallback(const Callback &callback) + { + m_importCallbacks.push_back(callback); + m_exportCallback(callback); + } + + typedef MemberCaller &), &ToggleItem::addCallback> AddCallbackCaller; +}; -inline void widget_toggle_visible( GtkWidget* widget ){ - widget_set_visible( widget, !widget_is_visible( widget ) ); -} +class ToggleShown { + bool m_shownDeferred; + + ToggleShown(const ToggleShown &other); // NOT COPYABLE + ToggleShown &operator=(const ToggleShown &other); // NOT ASSIGNABLE + + static gboolean notify_visible(ui::Widget widget, gpointer dummy, ToggleShown *self); + + static gboolean destroy(ui::Widget widget, ToggleShown *self); -class ToggleItem -{ -BoolExportCallback m_exportCallback; -typedef std::list ImportCallbacks; -ImportCallbacks m_importCallbacks; public: -ToggleItem( const BoolExportCallback& exportCallback ) : m_exportCallback( exportCallback ){ -} + ui::Widget m_widget; + ToggleItem m_item; -void update(){ - for ( ImportCallbacks::iterator i = m_importCallbacks.begin(); i != m_importCallbacks.end(); ++i ) - { - m_exportCallback( *i ); - } -} + ToggleShown(bool shown) + : m_shownDeferred(shown), m_widget(ui::null), m_item(ActiveCaller(*this)) + { + } -void addCallback( const BoolImportCallback& callback ){ - m_importCallbacks.push_back( callback ); - m_exportCallback( callback ); -} -typedef MemberCaller1 AddCallbackCaller; -}; + void update(); -class ToggleShown -{ -bool m_shownDeferred; + bool active() const; -ToggleShown( const ToggleShown& other ); // NOT COPYABLE -ToggleShown& operator=( const ToggleShown& other ); // NOT ASSIGNABLE + void exportActive(const Callback &importCallback); -static gboolean notify_visible( GtkWidget* widget, gpointer dummy, ToggleShown* self ){ - self->update(); - return FALSE; -} -static gboolean destroy( GtkWidget* widget, ToggleShown* self ){ - self->m_shownDeferred = GTK_WIDGET_VISIBLE( self->m_widget ) != FALSE; - self->m_widget = 0; - return FALSE; -} -public: -GtkWidget* m_widget; -ToggleItem m_item; + typedef MemberCaller &), &ToggleShown::exportActive> ActiveCaller; -ToggleShown( bool shown ) - : m_shownDeferred( shown ), m_widget( 0 ), m_item( ActiveCaller( *this ) ){ -} -void update(){ - m_item.update(); -} -bool active() const { - if ( m_widget == 0 ) { - return m_shownDeferred; - } - else - { - return GTK_WIDGET_VISIBLE( m_widget ) != FALSE; - } -} -void exportActive( const BoolImportCallback& importCallback ){ - importCallback( active() ); -} -typedef MemberCaller1 ActiveCaller; -void set( bool shown ){ - if ( m_widget == 0 ) { - m_shownDeferred = shown; - } - else - { - widget_set_visible( m_widget, shown ); - } -} -void toggle(){ - widget_toggle_visible( m_widget ); -} -typedef MemberCaller ToggleCaller; -void connect( GtkWidget* widget ){ - m_widget = widget; - widget_set_visible( m_widget, m_shownDeferred ); - g_signal_connect( G_OBJECT( m_widget ), "notify::visible", G_CALLBACK( notify_visible ), this ); - g_signal_connect( G_OBJECT( m_widget ), "destroy", G_CALLBACK( destroy ), this ); - update(); -} + void set(bool shown); + + void toggle(); + + typedef MemberCaller ToggleCaller; + + void connect(ui::Widget widget); }; diff --cc libs/gtkutil/window.cpp index 11b6efeb,74b724fd..eee5b582 --- a/libs/gtkutil/window.cpp +++ b/libs/gtkutil/window.cpp @@@ -26,9 -26,15 +26,15 @@@ #include "pointer.h" #include "accelerator.h" -inline void CHECK_RESTORE( GtkWidget* w ){ +inline void CHECK_RESTORE( ui::Widget w ){ if ( gpointer_to_int( g_object_get_data( G_OBJECT( w ), "was_mapped" ) ) != 0 ) { - gtk_widget_show( w ); + w.show(); + /* 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 ); + } } } @@@ -89,7 -95,24 +95,24 @@@ ui::Window create_floating_window( cons gtk_window_set_transient_for( window, 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 ); + window.connect( "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 --cc radiant/groupdialog.cpp index 1be74bf7,dc94603b..22c6150a --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@@ -57,10 -61,18 +57,18 @@@ void Create( ui::Window 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 ) ); + m_window.show(); } void Hide(){ - gtk_widget_hide( GTK_WIDGET( m_window ) ); + m_window.hide(); } WindowPositionTracker m_position_tracker; diff --cc radiant/gtkmisc.cpp index 85554502,59dab2a9..702f6ac4 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@@ -43,7 -43,7 +43,6 @@@ #include "gtkutil/dialog.h" #include "gtkutil/filechooser.h" #include "gtkutil/menu.h" --#include "gtkutil/toolbar.h" #include "commands.h" diff --cc radiant/gtkmisc.h index e867d6a2,14cdd816..2019452b --- a/radiant/gtkmisc.h +++ b/radiant/gtkmisc.h @@@ -31,7 -31,14 +31,8 @@@ #if !defined( INCLUDED_GTKMISC_H ) #define INCLUDED_GTKMISC_H -#include - -inline void process_gui(){ - while ( gtk_events_pending() ) - { - gtk_main_iteration(); - } -} +#include ++#include "gtkutil/toolbar.h" void command_connect_accelerator( const char* commandName ); void command_disconnect_accelerator( const char* commandName ); diff --cc radiant/mainframe.cpp index 208d8043,147d1a65..c8078621 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@@ -3057,12 -2914,14 +3057,14 @@@ void MainFrame::Create() GlobalCamera_setCamWnd( *m_pCamWnd ); { - GtkFrame* frame = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + auto frame = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) ); + window.add(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 ) ); + g_floating_windows.push_back( window ); } { @@@ -3076,12 -2935,14 +3078,14 @@@ { - GtkFrame* frame = create_framed_widget( m_pXYWnd->GetWidget() ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + auto frame = create_framed_widget( m_pXYWnd->GetWidget() ); + window.add(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 ) ); + g_floating_windows.push_back( window ); } { @@@ -3099,8 -2960,10 +3103,10 @@@ } 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 ) ); + g_floating_windows.push_back( window ); } { @@@ -3118,13 -2981,18 +3124,18 @@@ } 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 ) ); + g_floating_windows.push_back( window ); } { - GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) ); - g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() ); + auto frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) ); + g_page_textures = GroupDialog_addPage( "Textures", 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(); @@@ -3150,14 -3018,16 +3161,16 @@@ m_pXZWnd = new XYWnd(); m_pXZWnd->SetViewType( XZ ); - GtkWidget* xz = m_pXZWnd->GetWidget(); + ui::Widget xz = m_pXZWnd->GetWidget(); - GtkHPaned* split = create_split_views( camera, yz, xy, xz ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( split ), TRUE, TRUE, 0 ); + auto split = create_split_views( camera, yz, xy, xz ); + vbox.pack_start( split, TRUE, TRUE, 0 ); { - GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( window ) ); - g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() ); + auto frame = create_framed_widget( TextureBrowser_constructWindow( window ) ); + g_page_textures = GroupDialog_addPage( "Textures", 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 --cc radiant/texwindow.cpp index 1d766aea,cf1b6589..7a24d67f --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@@ -715,12 -646,10 +715,12 @@@ public void realise(){ m_realiseCallbacks(); /* texturebrowser tree update on vfs restart */ - TextureBrowser_constructTreeStore(); + // TextureBrowser_constructTreeStore(); } + void unrealise(){ } + void insert( const SignalHandler& handler ){ m_realiseCallbacks.connectLast( handler ); } @@@ -1869,8 -1764,12 +1869,12 @@@ ui::MenuItem TextureBrowser_constructVi 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" ); +ui::MenuItem TextureBrowser_constructToolsMenu( ui::Menu menu ){ + ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_Tools" )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@@ -2169,30 -2072,60 +2173,52 @@@ ui::Widget TextureBrowser_constructWind g_TextureBrowser.m_parent = 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, 0, 3, GTK_FILL, GTK_FILL, 0, 0 ); - gtk_widget_show( vbox ); + auto table = ui::Table(3, 3, FALSE); + auto vbox = ui::VBox(FALSE, 0); + table.attach(vbox, {0, 1, 1, 3}, {GTK_FILL, GTK_FILL}); + vbox.show(); - ui::Widget menu_bar{ui::null}; - //GtkWidget* menu_bar; - GtkToolbar* toolbar; ++ // ui::Widget menu_bar{ui::null}; ++ auto toolbar = ui::Toolbar::from( gtk_toolbar_new() ); { // menu bar - menu_bar = ui::Widget::from(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 ); ++ // menu_bar = ui::Widget::from(gtk_menu_bar_new()); + auto menu_view = ui::Menu(ui::New); - auto view_item = TextureBrowser_constructViewMenu( menu_view ); - gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view ); - gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), view_item ); ++ // auto view_item = TextureBrowser_constructViewMenu( menu_view ); ++ TextureBrowser_constructViewMenu( menu_view ); ++ // gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view ); ++ // gtk_menu_shell_append( GTK_MENU_SHELL( 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 ) ); ++ { ++ auto button = toolbar_append_button( toolbar, "View", "texbro_view.png" ); ++ button.dimensions( 22, 22 ); ++ button.connect( "clicked", G_CALLBACK( Popup_View_Menu ), menu_view ); ++ } ++ { ++ auto button = toolbar_append_button( toolbar, "Find / Replace...", "texbro_gtk-find-and-replace.png", "FindReplaceTextures" ); ++ button.dimensions( 22, 22 ); ++ } ++ { ++ auto button = toolbar_append_button( toolbar, "Flush & Reload Shaders", "texbro_refresh.png", "RefreshShaders" ); ++ button.dimensions( 22, 22 ); ++ } ++ toolbar.show(); + + /* - GtkWidget* menu_tools = gtk_menu_new(); - GtkWidget* tools_item = (GtkWidget*)TextureBrowser_constructToolsMenu( GTK_MENU( menu_tools ) ); + auto menu_tools = ui::Menu(ui::New); + auto tools_item = TextureBrowser_constructToolsMenu( 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_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tools_item ); - - table.attach(menu_bar, {0, 3, 0, 1}, {GTK_FILL, GTK_SHRINK}); - menu_bar.show(); + */ - //gtk_table_attach( GTK_TABLE( table ), menu_bar, 0, 3, 0, 1, GTK_FILL, GTK_SHRINK, 0, 0 ); - //gtk_widget_show( menu_bar ); ++ // table.attach(menu_bar, {0, 3, 0, 1}, {GTK_FILL, GTK_SHRINK}); ++ // menu_bar.show(); } { // Texture TreeView - g_TextureBrowser.m_scr_win_tree = gtk_scrolled_window_new( NULL, NULL ); + g_TextureBrowser.m_scr_win_tree = ui::ScrolledWindow(ui::New); gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tree ), 0 ); // vertical only scrolling for treeview @@@ -2246,13 -2179,28 +2272,18 @@@ TextureBrowser_buildTagList(); } { // 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 ); - - 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 menu_tags = ui::Menu(ui::New); - auto tags_item = 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 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 ); } { // 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 @@@ -2606,8 -2555,11 +2639,10 @@@ void TextureBrowser_RefreshShaders() else{ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" ); GlobalShaderSystem().refresh(); + /* texturebrowser tree update on vfs restart */ + TextureBrowser_constructTreeStore(); UpdateAllWindows(); } - } void TextureBrowser_ToggleShowShaders(){ @@@ -2865,5 -2812,9 +2900,9 @@@ void TextureBrowser_Construct() void TextureBrowser_Destroy(){ GlobalShaderSystem().detach( g_ShadersObserver ); - Textures_setModeChangedNotify( Callback() ); + Textures_setModeChangedNotify( Callback() ); } + -GtkWidget* TextureBrowser_getGLWidget(){ ++ui::Widget TextureBrowser_getGLWidget(){ + return GlobalTextureBrowser().m_gl_widget; + } diff --cc radiant/texwindow.h index 2d5125e4,d62c772a..d354c9df --- a/radiant/texwindow.h +++ b/radiant/texwindow.h @@@ -54,6 -59,6 +54,8 @@@ void TextureBrowser_setBackgroundColour void TextureBrowser_addActiveShadersChangedCallback( const SignalHandler& handler ); void TextureBrowser_addShadersRealiseCallback( const SignalHandler& handler ); -GtkWidget* TextureBrowser_getGLWidget(); +void TextureBrowser_RefreshShaders(); + ++ui::Widget TextureBrowser_getGLWidget(); + #endif