From ddbf0ec5978db5ca2b9acd96fafb19aedf1659a3 Mon Sep 17 00:00:00 2001 From: Pan7 Date: Mon, 3 Apr 2017 19:26:13 +0200 Subject: [PATCH] Replace deprecated GtkSignalFunc, gtk_container_children --- radiant/findtexturedialog.cpp | 10 +++++----- radiant/groupdialog.cpp | 11 ++++++----- radiant/groupdialog.h | 1 - radiant/gtkdlgs.cpp | 2 +- radiant/gtkmisc.cpp | 10 ++++++++-- radiant/gtkmisc.h | 8 ++++---- radiant/mainframe.cpp | 21 +++++++++++++-------- radiant/qe3.cpp | 27 ++++++++++++++++++--------- radiant/texwindow.cpp | 19 +++++++++++-------- 9 files changed, 66 insertions(+), 43 deletions(-) diff --git a/radiant/findtexturedialog.cpp b/radiant/findtexturedialog.cpp index ccc8bcc3..4be4ea6b 100644 --- a/radiant/findtexturedialog.cpp +++ b/radiant/findtexturedialog.cpp @@ -206,28 +206,28 @@ void FindTextureDialog::BuildDialog(){ gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnFind ), NULL ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); gtk_widget_show( button ); button = gtk_button_new_with_label( _( "OK" ) ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnOK ), NULL ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); gtk_widget_show( button ); button = gtk_button_new_with_label( _( "Apply" ) ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnApply ), NULL ); - gtk_widget_set_usize( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); + gtk_widget_show( button ); button = gtk_button_new_with_label( _( "Close" ) ); gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnClose ), NULL ); - gtk_widget_set_usize( button, 60, -2 ); - + gtk_widget_set_size_request( button, 60, -1 ); gtk_widget_show( dlg ); } diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index fda2a601..58e0baa2 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -307,10 +307,12 @@ bool UpdateSel( int iIndex, eclass_t *pec ){ // NOTE: these boxes might not even be on display for ( i = 0; i < last_count; i++ ) { - GtkWidget* widget = EntWidgets[EntCheck1 + i]; - gtk_label_set_text( GTK_LABEL( GTK_BIN( widget )->child ), " " ); - gtk_widget_hide( widget ); + GtkWidget *widget = EntWidgets[EntCheck1 + i]; + + gtk_button_set_label( GTK_BUTTON( widget ), " " ); + g_object_ref( widget ); + gtk_widget_hide( widget ); gtk_container_remove( GTK_CONTAINER( LayoutTable ), widget ); } last_count = spawnflag_count; @@ -330,7 +332,7 @@ bool UpdateSel( int iIndex, eclass_t *pec ){ (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); g_object_unref( widget ); - gtk_label_set_text( GTK_LABEL( GTK_BIN( widget )->child ), str.GetBuffer() ); + gtk_button_set_label( GTK_BUTTON( widget ), str.GetBuffer() ); } SetSpawnFlags(); @@ -1206,7 +1208,6 @@ static gint OnDialogKey( GtkWidget* widget, GdkEventKey* event, gpointer data ) GroupDlg::GroupDlg (){ m_pWidget = NULL; - m_hWorld = NULL; } #ifdef _WIN32 diff --git a/radiant/groupdialog.h b/radiant/groupdialog.h index 2adb2a43..62f3c1c7 100644 --- a/radiant/groupdialog.h +++ b/radiant/groupdialog.h @@ -96,7 +96,6 @@ public: GtkWidget* m_pNotebook; GtkWidget* m_pWidget; GtkWidget* m_pTree; - GtkCTreeNode* m_hWorld; //leo: not used keeping because of the win32 version }; extern GroupDlg *g_pGroupDlg; diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index f312eafa..b0f5bd4f 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -1249,7 +1249,7 @@ void DoEntityList(){ gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( entitylist_select ), dialog ); - gtk_widget_set_size_request( button, 60, -2 ); + gtk_widget_set_size_request( button, 60, -1 ); gtk_widget_show( button ); diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index 227e6fa7..2ec0e091 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -739,7 +739,7 @@ GtkWidget* create_sub_menu_with_mnemonic( GtkWidget *bar, const gchar *mnemonic extern void AddMenuItem( GtkWidget* menu, unsigned int id ); -GtkWidget* create_menu_item_with_mnemonic( GtkWidget *menu, const gchar *mnemonic, GtkSignalFunc func, int id ){ +GtkWidget* create_menu_item_with_mnemonic( GtkWidget *menu, const gchar *mnemonic, GCallback func, int id ){ GtkWidget *item; item = gtk_menu_item_new_with_mnemonic( mnemonic ); @@ -1694,11 +1694,17 @@ void CheckMenuSplitting( GtkWidget *&menu ){ // move the last 2 items to a submenu (3 because of win32) for ( int i = 0; i < 3; i++ ) { - item = GTK_WIDGET( g_list_last( gtk_container_get_children( GTK_CONTAINER( menu ) ) )->data ); + GList *children = gtk_container_get_children( GTK_CONTAINER( menu ) ) ; + if( !children ) { + continue; + } + item = GTK_WIDGET( g_list_last( children )->data ); g_object_ref( item ); gtk_container_remove( GTK_CONTAINER( menu ), item ); gtk_menu_shell_append( GTK_MENU_SHELL( menu2 ), item ); g_object_unref( item ); + + g_list_free( children ); } item = gtk_menu_item_new_with_label( "--------" ); diff --git a/radiant/gtkmisc.h b/radiant/gtkmisc.h index 4f86d24d..3f1d11a7 100644 --- a/radiant/gtkmisc.h +++ b/radiant/gtkmisc.h @@ -42,7 +42,7 @@ inline void get_window_pos( GtkWidget *wnd, int* x, int* y ){ #else inline void get_window_pos( GtkWidget *wnd, int* x, int* y ){ - gdk_window_get_root_origin( wnd->window, x, y ); + gdk_window_get_root_origin( gtk_widget_get_window( wnd ), x, y ); } #endif @@ -66,9 +66,9 @@ GtkWidget* new_plugin_image_icon( const char* filename ); GtkWidget* menu_separator( GtkWidget *menu ); GtkWidget* menu_tearoff( GtkWidget *menu ); GtkWidget* create_sub_menu_with_mnemonic( GtkWidget *bar, const gchar *mnemonic ); -GtkWidget* create_menu_item_with_mnemonic( GtkWidget *menu, const gchar *mnemonic, GtkSignalFunc func, int id ); -GtkWidget* create_check_menu_item_with_mnemonic( GtkWidget *menu, const gchar *mnemonic, GtkSignalFunc func, int id, gboolean active ); -GtkWidget* create_radio_menu_item_with_mnemonic( GtkWidget *menu, GtkWidget *last, const gchar *mnemonic, GtkSignalFunc func, int id, gboolean state ); +GtkWidget* create_menu_item_with_mnemonic( GtkWidget *menu, const gchar *mnemonic, GCallback func, int id ); +GtkWidget* create_check_menu_item_with_mnemonic( GtkWidget *menu, const gchar *mnemonic, GCallback func, int id, gboolean active ); +GtkWidget* create_radio_menu_item_with_mnemonic( GtkWidget *menu, GtkWidget *last, const gchar *mnemonic, GCallback func, int id, gboolean state ); GtkWidget* create_menu_in_menu_with_mnemonic( GtkWidget *menu, const gchar *mnemonic ); diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 6a11932a..76bfc800 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -4033,18 +4033,23 @@ void MainFrame::DoWatchBSP(){ void MainFrame::CleanPlugInMenu(){ GtkWidget *menu, *sep; - GList *lst; + GList *children, *seplst, *lst; // delete everything after the separator menu = GTK_WIDGET( g_object_get_data( G_OBJECT( m_pWidget ), "menu_plugin" ) ); sep = GTK_WIDGET( g_object_get_data( G_OBJECT( m_pWidget ), "menu_plugin_separator" ) ); m_nNextPlugInID = ID_PLUGIN_START; - lst = g_list_find( gtk_container_get_children( GTK_CONTAINER( menu ) ), sep ); - while ( lst->next ) - { - gtk_container_remove( GTK_CONTAINER( menu ), GTK_WIDGET( lst->next->data ) ); - lst = g_list_find( gtk_container_get_children( GTK_CONTAINER( menu ) ), sep ); + children = gtk_container_get_children( GTK_CONTAINER( menu ) ); + if( children ) { + seplst = g_list_find( children, sep ); + if( seplst ) { + for ( lst = g_list_next( seplst ); lst != NULL; lst = g_list_next( lst ) ) + { + gtk_container_remove( GTK_CONTAINER( menu ), GTK_WIDGET( lst->data ) ); + } + } + g_list_free( children ); } } @@ -4102,13 +4107,13 @@ inline GtkToolbarChildType gtktoolbarchildtype_for_toolbarbuttontype( IToolbarBu return (GtkToolbarChildType)0; } -void toolbar_insert( GtkWidget *toolbar, const char* image, const char* text, const char* tooltip, IToolbarButton::EType type, GtkSignalFunc handler, gpointer data ){ +void toolbar_insert( GtkWidget *toolbar, const char* image, const char* text, const char* tooltip, IToolbarButton::EType type, GCallback callback, gpointer data ){ GtkWidget *w, *pixmap; GdkPixmap *gdkpixmap; GdkBitmap *mask; pixmap = new_plugin_image_icon( image ); - w = gtk_toolbar_append_element( GTK_TOOLBAR( toolbar ), gtktoolbarchildtype_for_toolbarbuttontype( type ), NULL, text, tooltip, "", GTK_WIDGET( pixmap ), handler, data ); + w = gtk_toolbar_append_element( GTK_TOOLBAR( toolbar ), gtktoolbarchildtype_for_toolbarbuttontype( type ), NULL, text, tooltip, "", GTK_WIDGET( pixmap ), callback, data ); } void SignalToolbarButton( GtkWidget *widget, gpointer data ){ diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index c9b7094b..2b492ec2 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -1370,7 +1370,7 @@ static void MRU_SetText( int index, const char *filename ){ mnemonic[2] = '-'; mnemonic[3] = ' '; buffer_write_escaped_mnemonic( mnemonic + 4, filename ); - gtk_label_set_text_with_mnemonic( GTK_LABEL( GTK_BIN( MRU_items[index] )->child ), mnemonic ); + gtk_menu_item_set_label( GTK_MENU_ITEM( MRU_items[index] ), mnemonic ); } void MRU_Load(){ @@ -1447,7 +1447,7 @@ void MRU_Activate( int index ){ MRU_SetText( i, MRU_GetText( i + 1 ) ); if ( MRU_used == 0 ) { - gtk_label_set_text( GTK_LABEL( GTK_BIN( MRU_items[0] )->child ), _( "Recent Files" ) ); + gtk_menu_item_set_label( GTK_MENU_ITEM( MRU_items[0] ), _( "Recent Files" ) ); gtk_widget_set_sensitive( MRU_items[0], FALSE ); } else @@ -1541,17 +1541,23 @@ char *bsp_commands[256]; void FillBSPMenu(){ GtkWidget *item, *menu; // menu points to a GtkMenu (not an item) epair_t *ep; - GList *lst; + GList *children, *lst; int i; menu = GTK_WIDGET( g_object_get_data( G_OBJECT( g_qeglobals_gui.d_main_window ), "menu_bsp" ) ); - while ( ( lst = gtk_container_children( GTK_CONTAINER( menu ) ) ) != NULL ) - gtk_container_remove( GTK_CONTAINER( menu ), GTK_WIDGET( lst->data ) ); + children = gtk_container_get_children( GTK_CONTAINER( menu ) ); + if( children ) { + for ( lst = children; lst != NULL; lst = g_list_next( lst ) ) + { + gtk_container_remove( GTK_CONTAINER( menu ), GTK_WIDGET( lst->data ) ); + } + g_list_free( children ); + } if ( g_PrefsDlg.m_bDetachableMenus ) { item = gtk_tearoff_menu_item_new(); - gtk_menu_append( GTK_MENU( menu ), item ); + gtk_menu_shell_append( GTK_MENU_SHELL( menu ), item ); gtk_widget_set_sensitive( item, TRUE ); gtk_widget_show( item ); } @@ -1568,9 +1574,12 @@ void FillBSPMenu(){ i = 0; // first token is menu name - item = gtk_menu_get_attach_widget( GTK_MENU( menu ) ); - gtk_label_set_text( GTK_LABEL( GTK_BIN( item )->child ), token ); - + children = gtk_container_get_children( GTK_CONTAINER( menu ) ); + if( children ) { + if( g_list_first( children ) ) + gtk_label_set_text( GTK_LABEL( g_list_first( children )->data ), token ); + g_list_free( children ); + } token = strtok( NULL, ",;" ); while ( token != NULL ) { diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 3a09e7bc..f2f070df 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -547,7 +547,7 @@ void ClearGSList( GSList* lst ){ void FillTextureMenu( GSList** pArray ){ GtkWidget *menu, *sep, *item; // point to the Textures GtkMenu and to the last separator - GList *lst; + GList *children, *seplst, *lst; GSList *texdirs = NULL; GSList *texdirs_tmp = NULL; GSList *p; @@ -556,13 +556,16 @@ void FillTextureMenu( GSList** pArray ){ // delete everything menu = GTK_WIDGET( g_object_get_data( G_OBJECT( g_qeglobals_gui.d_main_window ), "menu_textures" ) ); sep = GTK_WIDGET( g_object_get_data( G_OBJECT( g_qeglobals_gui.d_main_window ), "menu_textures_separator" ) ); - lst = g_list_find( gtk_container_children( GTK_CONTAINER( menu ) ), sep ); - while ( lst->next ) - { - // these delete functions are recursive, it's gonna free all submenus - gtk_widget_destroy( GTK_WIDGET( lst->next->data ) ); - // lst is no longer relevant, need to get it again - lst = g_list_find( gtk_container_children( GTK_CONTAINER( menu ) ), sep ); + children = gtk_container_get_children( GTK_CONTAINER( menu ) ); + if( children ) { + seplst = g_list_find( children, sep ); + if( seplst ) { + for ( lst = g_list_next( seplst ); lst != NULL; lst = g_list_next( lst ) ) + { + gtk_widget_destroy( GTK_WIDGET( lst->data ) ); + } + } + g_list_free( children ); } texture_nummenus = 0;