From 6e9818d9cddf3880d001a544770c8c2c5187676f Mon Sep 17 00:00:00 2001 From: TimePath Date: Fri, 29 Dec 2017 20:28:05 +1100 Subject: [PATCH] Wrap more GTK --- contrib/bobtoolz/dialogs/dialogs-gtk.cpp | 29 +++++++++++------------- contrib/brushexport/interface.cpp | 2 +- contrib/camera/dialogs.cpp | 8 +++---- contrib/hydratoolz/plugin.cpp | 2 +- contrib/prtview/AboutDialog.cpp | 11 ++++----- contrib/prtview/ConfigDialog.cpp | 13 ++++------- contrib/prtview/LoadPortalFileDialog.cpp | 13 ++++------- contrib/sunplug/sunplug.cpp | 6 ++--- contrib/ufoaiplug/ufoai_gtk.cpp | 6 ++--- libs/gtkutil/dialog.cpp | 4 ++-- libs/gtkutil/filechooser.cpp | 4 ++-- libs/gtkutil/messagebox.cpp | 2 +- libs/gtkutil/widget.cpp | 20 +++------------- libs/gtkutil/widget.h | 9 -------- libs/gtkutil/window.cpp | 6 ++--- libs/uilib/uilib.cpp | 19 ++++++++++++++++ libs/uilib/uilib.h | 3 +++ radiant/build.cpp | 6 ++--- radiant/commands.cpp | 2 +- radiant/dialog.cpp | 6 ++--- radiant/entityinspector.cpp | 8 +++---- radiant/entitylist.cpp | 2 +- radiant/feedback.cpp | 4 ++-- radiant/groupdialog.cpp | 4 ++-- radiant/gtkdlgs.cpp | 20 ++++++++-------- radiant/gtkmisc.cpp | 2 +- radiant/mainframe.cpp | 12 +++++----- radiant/map.cpp | 4 ++-- radiant/mru.cpp | 16 ++++++------- radiant/patchmanip.cpp | 4 ++-- radiant/pluginmenu.cpp | 2 +- radiant/select.cpp | 8 +++---- radiant/textureentry.cpp | 2 +- radiant/texwindow.cpp | 14 ++++++------ radiant/xywindow.cpp | 4 ++-- 35 files changed, 132 insertions(+), 145 deletions(-) diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index 52f4f70a..dd08de2b 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -91,13 +91,10 @@ static void dialog_button_callback( GtkWidget *widget, gpointer data ){ *ret = (EMessageBoxReturn)gpointer_to_int( data ); } -static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){ - int *loop; - - gtk_widget_hide( widget ); - loop = (int*)g_object_get_data( G_OBJECT( widget ), "loop" ); +static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){ + widget.hide(); + int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop"); *loop = 0; - return TRUE; } @@ -305,7 +302,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess gtk_main_iteration(); gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return ret; } @@ -400,7 +397,7 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ rs->bDuplicateOnly = gtk_toggle_button_get_active( (GtkToggleButton*)check2 ) ? true : false; gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return ret; } @@ -567,7 +564,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ } gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return ret; } @@ -822,7 +819,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ } gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return ret; // -djbob @@ -1037,7 +1034,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ } gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return ret; //-djbob @@ -1210,7 +1207,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ } gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return ret; } @@ -1278,7 +1275,7 @@ EMessageBoxReturn DoCTFColourChangeBox(){ gtk_main_iteration(); gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return ret; } @@ -1609,7 +1606,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ } gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return ret; } @@ -1876,7 +1873,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ } gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return ret; } @@ -1988,7 +1985,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ } gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return ret; } diff --git a/contrib/brushexport/interface.cpp b/contrib/brushexport/interface.cpp index e06040d3..580b8dec 100644 --- a/contrib/brushexport/interface.cpp +++ b/contrib/brushexport/interface.cpp @@ -216,7 +216,7 @@ void CreateWindow( void ){ void DestroyWindow( void ){ ASSERT_NOTNULL( g_brushexp_window ); - gtk_widget_destroy( g_brushexp_window ); + ui::Widget(g_brushexp_window).destroy(); g_brushexp_window = 0; } diff --git a/contrib/camera/dialogs.cpp b/contrib/camera/dialogs.cpp index 9425521d..4504655c 100644 --- a/contrib/camera/dialogs.cpp +++ b/contrib/camera/dialogs.cpp @@ -171,7 +171,7 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ } gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return TRUE; } @@ -463,7 +463,7 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ } gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return TRUE; } @@ -629,7 +629,7 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ } gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return TRUE; } @@ -952,7 +952,7 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ } gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return TRUE; } diff --git a/contrib/hydratoolz/plugin.cpp b/contrib/hydratoolz/plugin.cpp index 5ca4fad1..52e79091 100644 --- a/contrib/hydratoolz/plugin.cpp +++ b/contrib/hydratoolz/plugin.cpp @@ -185,7 +185,7 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ gtk_main_iteration(); gtk_grab_remove( window ); - gtk_widget_destroy( window ); + window.destroy(); return ret; } diff --git a/contrib/prtview/AboutDialog.cpp b/contrib/prtview/AboutDialog.cpp index 64073032..0e342f40 100644 --- a/contrib/prtview/AboutDialog.cpp +++ b/contrib/prtview/AboutDialog.cpp @@ -39,13 +39,10 @@ static void dialog_button_callback( GtkWidget *widget, gpointer data ){ *ret = gpointer_to_int( data ); } -static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){ - int *loop; - - gtk_widget_hide( widget ); - loop = (int*)g_object_get_data( G_OBJECT( widget ), "loop" ); +static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){ + widget.hide(); + int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop"); *loop = 0; - return TRUE; } @@ -91,7 +88,7 @@ void DoAboutDlg(){ gtk_main_iteration(); gtk_grab_remove(dlg); - gtk_widget_destroy(dlg); + dlg.destroy(); } diff --git a/contrib/prtview/ConfigDialog.cpp b/contrib/prtview/ConfigDialog.cpp index 7599690d..86828d09 100644 --- a/contrib/prtview/ConfigDialog.cpp +++ b/contrib/prtview/ConfigDialog.cpp @@ -40,13 +40,10 @@ static void dialog_button_callback( GtkWidget *widget, gpointer data ){ *ret = gpointer_to_int( data ); } -static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){ - int *loop; - - gtk_widget_hide( widget ); - loop = (int*)g_object_get_data( G_OBJECT( widget ), "loop" ); +static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){ + widget.hide(); + int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop"); *loop = 0; - return TRUE; } @@ -83,7 +80,7 @@ static int DoColor( PackedColour *c ){ gtk_color_selection_get_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(dlg)) ), &clr ); gtk_grab_remove( dlg ); - gtk_widget_destroy( dlg ); + dlg.destroy(); if ( ret == IDOK ) { *c = RGB( clr.red / (65535 / 255), clr.green / (65535 / 255), clr.blue / (65535 / 255)); @@ -476,5 +473,5 @@ void DoConfigDialog(){ gtk_main_iteration(); gtk_grab_remove( dlg ); - gtk_widget_destroy( dlg ); + dlg.destroy(); } diff --git a/contrib/prtview/LoadPortalFileDialog.cpp b/contrib/prtview/LoadPortalFileDialog.cpp index 9a5348f1..b924e7fd 100644 --- a/contrib/prtview/LoadPortalFileDialog.cpp +++ b/contrib/prtview/LoadPortalFileDialog.cpp @@ -45,13 +45,10 @@ static void dialog_button_callback( GtkWidget *widget, gpointer data ){ *ret = gpointer_to_int( data ); } -static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){ - int *loop; - - gtk_widget_hide( widget ); - loop = (int*)g_object_get_data( G_OBJECT( widget ), "loop" ); +static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){ + widget.hide(); + int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop"); *loop = 0; - return TRUE; } @@ -70,7 +67,7 @@ static void change_clicked( GtkWidget *widget, gpointer data ){ { filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_sel)); } - gtk_widget_destroy (file_sel); + ui::Widget(file_sel).destroy(); if ( filename != NULL ) { strcpy( portals.fn, filename ); @@ -164,7 +161,7 @@ int DoLoadPortalFileDialog(){ } gtk_grab_remove( dlg ); - gtk_widget_destroy( dlg ); + dlg.destroy(); return ret; } diff --git a/contrib/sunplug/sunplug.cpp b/contrib/sunplug/sunplug.cpp index afa4b20d..ad9e11f2 100644 --- a/contrib/sunplug/sunplug.cpp +++ b/contrib/sunplug/sunplug.cpp @@ -125,13 +125,13 @@ static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data } // destroy widget if destroy signal is passed to widget -static void destroy( GtkWidget *widget, gpointer data ){ - gtk_widget_destroy( widget ); +static void destroy( ui::Widget widget, gpointer data ){ + widget.destroy(); } // function for close button to destroy the toplevel widget static void close_window( GtkWidget *widget, gpointer data ){ - gtk_widget_destroy( gtk_widget_get_toplevel( widget ) ); + ui::Widget(gtk_widget_get_toplevel( widget ) ).destroy(); } // callback function to assign the optimal mapcoords to the spinboxes diff --git a/contrib/ufoaiplug/ufoai_gtk.cpp b/contrib/ufoaiplug/ufoai_gtk.cpp index fa683feb..5b287c89 100644 --- a/contrib/ufoaiplug/ufoai_gtk.cpp +++ b/contrib/ufoaiplug/ufoai_gtk.cpp @@ -39,15 +39,15 @@ static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data /** * @brief destroy widget if destroy signal is passed to widget */ -static void destroy( GtkWidget *widget, gpointer data ){ - gtk_widget_destroy( widget ); +static void destroy( ui::Widget widget, gpointer data ){ + widget.destroy(); } /** * @brief function for close button to destroy the toplevel widget */ static void close_window( GtkWidget *widget, gpointer data ){ - gtk_widget_destroy( gtk_widget_get_toplevel( widget ) ); + ui::Widget(gtk_widget_get_toplevel( widget ) ).destroy(); } /* =============================== */ diff --git a/libs/gtkutil/dialog.cpp b/libs/gtkutil/dialog.cpp index 88ca8d32..20bd9cba 100644 --- a/libs/gtkutil/dialog.cpp +++ b/libs/gtkutil/dialog.cpp @@ -95,7 +95,7 @@ EMessageBoxReturn modal_dialog_show( ui::Window window, ModalDialog& dialog ){ gtk_main_iteration(); } - gtk_widget_hide( GTK_WIDGET( window ) ); + window.hide(); gtk_grab_remove( GTK_WIDGET( window ) ); return dialog.ret; @@ -152,7 +152,7 @@ gboolean dialog_button_no( ui::Widget widget, ModalDialog* data ){ } gboolean dialog_delete_callback( ui::Widget widget, GdkEventAny* event, ModalDialog* data ){ - gtk_widget_hide( widget ); + widget.hide(); data->loop = false; return TRUE; } diff --git a/libs/gtkutil/filechooser.cpp b/libs/gtkutil/filechooser.cpp index a06c4c93..c2c74c2f 100644 --- a/libs/gtkutil/filechooser.cpp +++ b/libs/gtkutil/filechooser.cpp @@ -230,7 +230,7 @@ const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, c g_file_dialog_file[0] = '\0'; } - gtk_widget_destroy( dialog ); + ui::Widget(dialog).destroy(); // don't return an empty filename if ( g_file_dialog_file[0] == '\0' ) { @@ -260,7 +260,7 @@ char* dir_dialog( ui::Widget parent, const char* title, const char* path ){ filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( dialog ) ); } - gtk_widget_destroy( dialog ); + ui::Widget(dialog).destroy(); return filename; } diff --git a/libs/gtkutil/messagebox.cpp b/libs/gtkutil/messagebox.cpp index 97b8db54..1441b00d 100644 --- a/libs/gtkutil/messagebox.cpp +++ b/libs/gtkutil/messagebox.cpp @@ -190,7 +190,7 @@ EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const cha modal_dialog_show( window, dialog ); - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); return dialog.ret; } diff --git a/libs/gtkutil/widget.cpp b/libs/gtkutil/widget.cpp index 579ade80..162f992a 100644 --- a/libs/gtkutil/widget.cpp +++ b/libs/gtkutil/widget.cpp @@ -1,20 +1,6 @@ #include "widget.h" #include -void widget_set_visible(ui::Widget widget, bool shown) -{ - if (shown) { - widget.show(); - } else { - gtk_widget_hide(widget); - } -} - -bool widget_is_visible(ui::Widget widget) -{ - return gtk_widget_get_visible(widget) != FALSE; -} - void widget_queue_draw(ui::Widget &widget) { gtk_widget_queue_draw(widget); @@ -63,19 +49,19 @@ void ToggleShown::set(bool shown) if (!m_widget) { m_shownDeferred = shown; } else { - widget_set_visible(m_widget, shown); + m_widget.visible(shown); } } void ToggleShown::toggle() { - widget_toggle_visible(m_widget); + m_widget.visible(!m_widget.visible()); } void ToggleShown::connect(ui::Widget widget) { m_widget = widget; - widget_set_visible(m_widget, m_shownDeferred); + m_widget.visible(m_shownDeferred); m_widget.connect("notify::visible", G_CALLBACK(notify_visible), this); m_widget.connect("destroy", G_CALLBACK(destroy), this); update(); diff --git a/libs/gtkutil/widget.h b/libs/gtkutil/widget.h index a81054d4..76b318dc 100644 --- a/libs/gtkutil/widget.h +++ b/libs/gtkutil/widget.h @@ -29,15 +29,6 @@ #include "warnings.h" #include "debugging/debugging.h" -void widget_set_visible(ui::Widget widget, bool shown); - -bool widget_is_visible(ui::Widget widget); - -inline void widget_toggle_visible(ui::Widget widget) -{ - widget_set_visible(widget, !widget_is_visible(widget)); -} - class ToggleItem { BoolExportCallback m_exportCallback; typedef std::list ImportCallbacks; diff --git a/libs/gtkutil/window.cpp b/libs/gtkutil/window.cpp index 6986d6d9..7fc62eae 100644 --- a/libs/gtkutil/window.cpp +++ b/libs/gtkutil/window.cpp @@ -34,7 +34,7 @@ inline void CHECK_RESTORE( ui::Widget w ){ inline void CHECK_MINIMIZE( ui::Widget w ){ g_object_set_data( G_OBJECT( w ), "was_mapped", gint_to_pointer( gtk_widget_get_visible( w ) ) ); - gtk_widget_hide( w ); + w.hide(); } static gboolean main_window_iconified( ui::Widget widget, GdkEventWindowState* event, gpointer data ){ @@ -96,7 +96,7 @@ ui::Window create_floating_window( const char* title, ui::Window parent ){ } void destroy_floating_window( ui::Window window ){ - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); } gint window_realize_remove_sysmenu( ui::Widget widget, gpointer data ){ @@ -105,7 +105,7 @@ gint window_realize_remove_sysmenu( ui::Widget widget, gpointer data ){ } gboolean persistent_floating_window_delete( ui::Window floating, GdkEvent *event, ui::Window main_window ){ - gtk_widget_hide( GTK_WIDGET( floating ) ); + floating.hide(); return TRUE; } diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 4832d92f..d3cd1972 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -97,11 +97,25 @@ namespace ui { return gtk_widget_get_visible(this) != 0; } + void IWidget::visible(bool shown) + { + if (shown) { + this.show(); + } else { + this.hide(); + } + } + void IWidget::show() { gtk_widget_show(this); } + void IWidget::hide() + { + gtk_widget_hide(this); + } + Dimensions IWidget::dimensions() { GtkAllocation allocation; @@ -114,6 +128,11 @@ namespace ui { gtk_widget_set_size_request(this, width, height); } + void IWidget::destroy() + { + gtk_widget_destroy(this); + } + IMPL(Container, GTK_CONTAINER); void IContainer::add(Widget widget) diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index b4d315c9..5d8a48fb 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -259,9 +259,12 @@ namespace ui { bool want_save = false ); bool visible(); + void visible(bool shown); void show(); + void hide(); Dimensions dimensions(); void dimensions(int width, int height); + void destroy(); ); WRAP(Container, Widget, _GtkContainer, (), diff --git a/radiant/build.cpp b/radiant/build.cpp index 13938ce1..83767446 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -734,7 +734,7 @@ Build* g_current_build = 0; gboolean project_selection_changed( GtkTreeSelection* selection, ui::ListStore store ){ Project& project = g_build_project; - gtk_list_store_clear( store ); + store.clear(); GtkTreeIter iter; GtkTreeModel* model; @@ -957,7 +957,7 @@ void DoBuildMenu(){ g_build_changed = true; } - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); } @@ -1005,7 +1005,7 @@ void Build_constructMenu( ui::Menu menu ){ void Build_refreshMenu( ui::Menu menu ){ for ( BuildMenuItems::iterator i = g_BuildMenuItems.begin(); i != g_BuildMenuItems.end(); ++i ) { - gtk_container_remove( menu, GTK_WIDGET( ( *i ).m_item ) ); + menu.remove(ui::Widget(GTK_WIDGET((*i).m_item))); } g_BuildMenuItems.clear(); diff --git a/radiant/commands.cpp b/radiant/commands.cpp index 70aa4975..6b42e65a 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -482,7 +482,7 @@ public: } modal_dialog_show( window, dialog ); - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); } #include "profile/profile.h" diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index 8133cdb0..701a8f1e 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -319,7 +319,7 @@ void Dialog::ShowDlg(){ void Dialog::HideDlg(){ ASSERT_MESSAGE( m_window, "dialog was not constructed" ); exportData(); - gtk_widget_hide( GTK_WIDGET( m_window ) ); + m_window.hide(); } static gint delete_event_callback( ui::Widget widget, GdkEvent* event, gpointer data ){ @@ -338,7 +338,7 @@ void Dialog::Create(){ void Dialog::Destroy(){ ASSERT_MESSAGE( m_window, "dialog cannot be destroyed" ); - gtk_widget_destroy( GTK_WIDGET( m_window ) ); + m_window.destroy(); m_window = ui::Window{ui::null}; } @@ -445,7 +445,7 @@ EMessageBoxReturn Dialog::DoModal(){ exportData(); } - gtk_widget_hide( GTK_WIDGET( m_window ) ); + m_window.hide(); PostModal( m_modal.ret ); diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 42889c61..8c67825e 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -820,7 +820,7 @@ void EntityClassList_fill(){ } void EntityClassList_clear(){ - gtk_list_store_clear( g_entlist_store ); + g_entlist_store.clear(); } void SetComment( EntityClass* eclass ){ @@ -861,9 +861,9 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){ auto widget = ui::Widget(GTK_WIDGET(g_entitySpawnflagsCheck[i])); auto label = ui::Label(GTK_LABEL(gtk_bin_get_child(GTK_BIN(widget)))); label.text(" "); - gtk_widget_hide( widget ); + widget.hide(); g_object_ref( widget ); - gtk_container_remove( GTK_CONTAINER( g_spawnflagsTable ), widget ); + ui::Container(GTK_CONTAINER(g_spawnflagsTable)).remove(widget); } } @@ -1041,7 +1041,7 @@ void EntityInspector_updateKeyValues(){ CopiedString strKey( g_entityKeyEntry.text() ); CopiedString strVal( g_entityValueEntry.text() ); - gtk_list_store_clear( store ); + store.clear(); // Walk through list and add pairs for ( KeyValues::iterator i = g_selectedKeyValues.begin(); i != g_selectedKeyValues.end(); ++i ) { diff --git a/radiant/entitylist.cpp b/radiant/entitylist.cpp index 8b6a4690..8f677c2f 100644 --- a/radiant/entitylist.cpp +++ b/radiant/entitylist.cpp @@ -244,7 +244,7 @@ void entitylist_treeview_row_expanded( GtkTreeView* view, GtkTreeIter* iter, Gtk void EntityList_SetShown( bool shown ){ - widget_set_visible( getEntityList().m_window, shown ); + getEntityList().m_window.visible(shown); } void EntityList_toggleShown(){ diff --git a/radiant/feedback.cpp b/radiant/feedback.cpp index 1fc3611f..a465ed6c 100644 --- a/radiant/feedback.cpp +++ b/radiant/feedback.cpp @@ -266,7 +266,7 @@ void CDbgDlg::Init(){ } if ( m_clist ) { - gtk_list_store_clear( m_clist ); + m_clist.clear(); } } @@ -279,7 +279,7 @@ void CDbgDlg::Push( ISAXHandler *pHandler ){ } // put stuff in the list - gtk_list_store_clear( m_clist ); + m_clist.clear(); for ( std::size_t i = 0; i < static_cast( m_pFeedbackElements->len ); ++i ) { m_clist.append(0, GetElement(i)->getName()); diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index 1eeb35b2..261d625b 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -60,7 +60,7 @@ void Show(){ m_window.show(); } void Hide(){ - gtk_widget_hide( GTK_WIDGET( m_window ) ); + m_window.hide(); } WindowPositionTracker m_position_tracker; @@ -134,7 +134,7 @@ ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const S bool GroupDialog_isShown(){ - return widget_is_visible( g_GroupDlg.m_window ); + return g_GroupDlg.m_window.visible(); } void GroupDialog_setShown( bool shown ){ shown ? g_GroupDlg.Show() : g_GroupDlg.Hide(); diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index 278edab1..6c70e557 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -360,7 +360,7 @@ void DoProjectSettings(){ ProjectSettingsDialog_ok( dialog ); } - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); } } @@ -414,7 +414,7 @@ void DoSides( int type, int axis ){ Scene_BrushConstructPrefab( GlobalSceneGraph(), (EBrushPrefab)type, atoi( str ), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) ); } - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); } // ============================================================================= @@ -581,7 +581,7 @@ void DoAbout(){ modal_dialog_show( window, dialog ); - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); } // ============================================================================= @@ -697,7 +697,7 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ last_used_texture_layout_scale_y = *fy; } - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); return ret; } @@ -714,7 +714,7 @@ static gint editor_delete( ui::Widget widget, gpointer data ){ return TRUE; } - gtk_widget_hide( text_editor ); + text_editor.hide(); return TRUE; } @@ -738,7 +738,7 @@ static void editor_close( ui::Widget widget, gpointer data ){ return; } - gtk_widget_hide( text_editor ); + text_editor.hide(); } static void CreateGtkTextEditor(){ @@ -797,7 +797,7 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos ){ if ( f == 0 ) { globalOutputStream() << "Unable to load file " << filename << " in shader editor.\n"; - gtk_widget_hide( text_editor ); + text_editor.hide(); } else { @@ -909,7 +909,7 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ *intensity = atoi( gtk_entry_get_text( intensity_entry ) ); } - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); return ret; } @@ -973,7 +973,7 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, const char* title ){ *tag = gtk_entry_get_text( textentry ); } - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); return ret; } @@ -1024,7 +1024,7 @@ EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, const EMessageBoxReturn ret = modal_dialog_show( window, dialog ); - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); return ret; } diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index 76ad6e16..0f210221 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -121,7 +121,7 @@ bool color_dialog( ui::Widget parent, Vector3& color, const char* title ){ color[2] = clr.blue / 65535.0f; } - gtk_widget_destroy( dlg ); + dlg.destroy(); return ok; } diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 5868e288..26d6b1b2 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -2532,16 +2532,16 @@ MainFrame::MainFrame() : m_idleRedrawStatusText( RedrawStatusTextCaller( *this ) MainFrame::~MainFrame(){ SaveWindowInfo(); - gtk_widget_hide( GTK_WIDGET( m_window ) ); + m_window.hide(); Shutdown(); for ( std::vector::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i ) { - gtk_widget_destroy( *i ); + i->destroy(); } - gtk_widget_destroy( GTK_WIDGET( m_window ) ); + m_window.destroy(); } void MainFrame::SetActiveXY( XYWnd* p ){ @@ -2689,7 +2689,7 @@ void show_splash(){ } void hide_splash(){ - gtk_widget_destroy( GTK_WIDGET( splash_screen ) ); + splash_screen.destroy(); } WindowPositionTracker g_posCamWnd; @@ -2752,9 +2752,9 @@ void MainFrame::Create(){ GtkToolbar* main_toolbar = create_main_toolbar( CurrentStyle() ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_toolbar ), FALSE, FALSE, 0 ); - GtkToolbar* plugin_toolbar = create_plugin_toolbar(); + auto plugin_toolbar = create_plugin_toolbar(); if ( !g_Layout_enablePluginToolbar.m_value ) { - gtk_widget_hide( GTK_WIDGET( plugin_toolbar ) ); + plugin_toolbar.hide(); } gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( plugin_toolbar ), FALSE, FALSE, 0 ); diff --git a/radiant/map.cpp b/radiant/map.cpp index 1905c60b..fff85c1f 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -896,7 +896,7 @@ void DoMapInfo(){ // save before exit window_get_position( window, g_posMapInfoWnd ); - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); } @@ -2114,7 +2114,7 @@ void DoFind(){ SelectBrush( atoi( entstr ), atoi( brushstr ) ); } - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); } void Map_constructPreferences( PreferencesPage& page ){ diff --git a/radiant/mru.cpp b/radiant/mru.cpp index 9aef5dcb..71133c55 100644 --- a/radiant/mru.cpp +++ b/radiant/mru.cpp @@ -165,7 +165,7 @@ void MRU_Activate( std::size_t index ){ } else { - gtk_widget_hide( GTK_WIDGET( MRU_items[MRU_used] ) ); + ui::MenuItem(MRU_items[MRU_used]).hide(); } } } @@ -194,23 +194,23 @@ LoadMRU g_load_mru4( 4 ); void MRU_constructMenu( ui::Menu menu ){ { - GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_1", LoadMRUCaller( g_load_mru1 ) ); + auto item = create_menu_item_with_mnemonic( menu, "_1", LoadMRUCaller( g_load_mru1 ) ); gtk_widget_set_sensitive( GTK_WIDGET( item ), FALSE ); MRU_AddWidget( item, 0 ); } { - GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_2", LoadMRUCaller( g_load_mru2 ) ); - gtk_widget_hide( GTK_WIDGET( item ) ); + auto item = create_menu_item_with_mnemonic( menu, "_2", LoadMRUCaller( g_load_mru2 ) ); + item.hide(); MRU_AddWidget( item, 1 ); } { - GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_3", LoadMRUCaller( g_load_mru3 ) ); - gtk_widget_hide( GTK_WIDGET( item ) ); + auto item = create_menu_item_with_mnemonic( menu, "_3", LoadMRUCaller( g_load_mru3 ) ); + item.hide(); MRU_AddWidget( item, 2 ); } { - GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_4", LoadMRUCaller( g_load_mru4 ) ); - gtk_widget_hide( GTK_WIDGET( item ) ); + auto item = create_menu_item_with_mnemonic( menu, "_4", LoadMRUCaller( g_load_mru4 ) ); + item.hide(); MRU_AddWidget( item, 3 ); } } diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index 677abbd5..2bb141a1 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -959,7 +959,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), prefab, GlobalXYWnd_getCurrentViewType(), w, h ); } - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); } @@ -1125,7 +1125,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ } } - gtk_widget_destroy( GTK_WIDGET( window ) ); + window.destroy(); return ret; } diff --git a/radiant/pluginmenu.cpp b/radiant/pluginmenu.cpp index 69e5c084..cd05d714 100644 --- a/radiant/pluginmenu.cpp +++ b/radiant/pluginmenu.cpp @@ -149,7 +149,7 @@ void PluginsMenu_clear(){ GList* lst = g_list_find( gtk_container_get_children( GTK_CONTAINER( g_plugins_menu ) ), GTK_WIDGET( g_plugins_menu_separator ) ); while ( lst->next ) { - gtk_container_remove( GTK_CONTAINER( g_plugins_menu ), GTK_WIDGET( lst->next->data ) ); + g_plugins_menu.remove(ui::Widget(GTK_WIDGET(lst->next->data))); lst = g_list_find( gtk_container_get_children( GTK_CONTAINER( g_plugins_menu ) ), GTK_WIDGET( g_plugins_menu_separator ) ); } } diff --git a/radiant/select.cpp b/radiant/select.cpp index 20c6f730..3c3b2060 100644 --- a/radiant/select.cpp +++ b/radiant/select.cpp @@ -887,7 +887,7 @@ static gboolean rotatedlg_apply( ui::Widget widget, RotateDialog* rotateDialog ) } static gboolean rotatedlg_cancel( ui::Widget widget, RotateDialog* rotateDialog ){ - gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) ); + rotateDialog->window.hide(); gtk_spin_button_set_value( rotateDialog->x, 0.0f ); // reset to 0 on close gtk_spin_button_set_value( rotateDialog->y, 0.0f ); @@ -898,7 +898,7 @@ static gboolean rotatedlg_cancel( ui::Widget widget, RotateDialog* rotateDialog static gboolean rotatedlg_ok( ui::Widget widget, RotateDialog* rotateDialog ){ rotatedlg_apply( widget, rotateDialog ); - gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) ); + rotateDialog->window.hide(); return TRUE; } @@ -1039,7 +1039,7 @@ static gboolean scaledlg_apply( ui::Widget widget, ScaleDialog* scaleDialog ){ } static gboolean scaledlg_cancel( ui::Widget widget, ScaleDialog* scaleDialog ){ - gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) ); + scaleDialog->window.hide(); scaleDialog->x.text("1.0"); scaleDialog->y.text("1.0"); @@ -1050,7 +1050,7 @@ static gboolean scaledlg_cancel( ui::Widget widget, ScaleDialog* scaleDialog ){ static gboolean scaledlg_ok( ui::Widget widget, ScaleDialog* scaleDialog ){ scaledlg_apply( widget, scaleDialog ); - gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) ); + scaleDialog->window.hide(); return TRUE; } diff --git a/radiant/textureentry.cpp b/radiant/textureentry.cpp index c4bac5a1..6e6e9de8 100644 --- a/radiant/textureentry.cpp +++ b/radiant/textureentry.cpp @@ -55,7 +55,7 @@ void EntryCompletion::fill() template void EntryCompletion::clear() { - gtk_list_store_clear(m_store); + m_store.clear(); } template diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 5c0e6467..b743fddd 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -674,7 +674,7 @@ void TextureBrowser_activeShadersChanged( TextureBrowser& textureBrowser ){ void TextureBrowser_importShowScrollbar( TextureBrowser& textureBrowser, bool value ){ textureBrowser.m_showTextureScrollbar = value; if ( textureBrowser.m_texture_scroll != 0 ) { - widget_set_visible( textureBrowser.m_texture_scroll, textureBrowser.m_showTextureScrollbar ); + textureBrowser.m_texture_scroll.visible(textureBrowser.m_showTextureScrollbar); TextureBrowser_updateScroll( textureBrowser ); } } @@ -1299,7 +1299,7 @@ enum void BuildStoreAssignedTags( ui::ListStore store, const char* shader, TextureBrowser* textureBrowser ){ GtkTreeIter iter; - gtk_list_store_clear( store ); + store.clear(); std::vector assigned_tags; TagBuilder.GetShaderTags( shader, assigned_tags ); @@ -1319,7 +1319,7 @@ void BuildStoreAvailableTags( ui::ListStore storeAvailable, std::set::const_iterator iterAll; gchar* tag_assigned; - gtk_list_store_clear( storeAvailable ); + storeAvailable.clear(); bool row = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( storeAssigned ), &iterAssigned ) != 0; @@ -1379,7 +1379,7 @@ gboolean TextureBrowser_button_press( ui::Widget widget, GdkEventButton* event, if ( GlobalTextureBrowser().m_tags ) { textureBrowser->m_rmbSelected = false; - gtk_widget_hide( textureBrowser->m_tag_frame ); + textureBrowser->m_tag_frame.hide(); } } } @@ -1828,7 +1828,7 @@ void TextureBrowser_removeTags(){ } void TextureBrowser_buildTagList(){ - gtk_list_store_clear( g_TextureBrowser.m_all_tags_list ); + g_TextureBrowser.m_all_tags_list.clear(); std::set::iterator iter; @@ -1915,7 +1915,7 @@ void TextureBrowser_toggleSearchButton(){ gtk_widget_show_all( g_TextureBrowser.m_search_button ); } else { - gtk_widget_hide( g_TextureBrowser.m_search_button ); + g_TextureBrowser.m_search_button.hide(); } } @@ -2047,7 +2047,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ auto vadjustment = ui::Adjustment(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 ); diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 61a7a021..40f881d1 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -861,7 +861,7 @@ XYWnd::~XYWnd(){ onDestroyed(); if ( m_mnuDrop ) { - gtk_widget_destroy( GTK_WIDGET( m_mnuDrop ) ); + m_mnuDrop.destroy(); m_mnuDrop = ui::Menu(ui::null); } @@ -2570,7 +2570,7 @@ void realise(){ void unrealise(){ if ( ++m_unrealised == 1 ) { if ( XYWnd::m_mnuDrop ) { - gtk_widget_destroy( GTK_WIDGET( XYWnd::m_mnuDrop ) ); + XYWnd::m_mnuDrop.destroy(); XYWnd::m_mnuDrop = ui::Menu(ui::null); } } -- 2.39.2