From cab6f1e40f69020aae8c59d45ab51a026ee3e6f6 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 22 Jul 2017 01:49:35 +1000 Subject: [PATCH] Wrap gtkutil/widget --- libs/gtkutil/messagebox.cpp | 28 ++++++++++++++-------------- libs/gtkutil/widget.h | 30 +++++++++++++++--------------- radiant/camwindow.cpp | 2 +- radiant/commands.cpp | 4 ++-- radiant/entitylist.cpp | 2 +- radiant/groupdialog.cpp | 2 +- radiant/gtkdlgs.cpp | 20 ++++++++++---------- radiant/map.cpp | 4 ++-- radiant/patchmanip.cpp | 8 ++++---- radiant/select.cpp | 8 ++++---- radiant/xywindow.cpp | 6 +++--- 11 files changed, 57 insertions(+), 57 deletions(-) diff --git a/libs/gtkutil/messagebox.cpp b/libs/gtkutil/messagebox.cpp index 8930145b..86ed48c3 100644 --- a/libs/gtkutil/messagebox.cpp +++ b/libs/gtkutil/messagebox.cpp @@ -108,22 +108,22 @@ EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const cha if ( type == eMB_OK ) { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + widget_make_default( button ); + button.show(); dialog.ret = eIDOK; } else if ( type == eMB_OKCANCEL ) { { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + widget_make_default( button ); + button.show(); } { @@ -137,10 +137,10 @@ EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const cha } else if ( type == eMB_YESNOCANCEL ) { { - GtkButton* button = create_modal_dialog_button( "Yes", yes_button ); + auto button = create_modal_dialog_button( "Yes", yes_button ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + widget_make_default( button ); + button.show(); } { @@ -158,10 +158,10 @@ EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const cha } else if ( type == eMB_NOYES ) { { - GtkButton* button = create_modal_dialog_button( "No", no_button ); + auto button = create_modal_dialog_button( "No", no_button ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_show( GTK_WIDGET( button ) ); + widget_make_default( button ); + button.show(); } { GtkButton* button = create_modal_dialog_button( "Yes", yes_button ); @@ -174,9 +174,9 @@ EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const cha else /* if (type == eMB_YESNO) */ { { - GtkButton* button = create_modal_dialog_button( "Yes", yes_button ); + auto button = create_modal_dialog_button( "Yes", yes_button ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_show( GTK_WIDGET( button ) ); } diff --git a/libs/gtkutil/widget.h b/libs/gtkutil/widget.h index bf84eef0..77938c64 100644 --- a/libs/gtkutil/widget.h +++ b/libs/gtkutil/widget.h @@ -28,9 +28,9 @@ #include "warnings.h" #include "debugging/debugging.h" -inline void widget_set_visible( GtkWidget* widget, bool shown ){ +inline void widget_set_visible( ui::Widget widget, bool shown ){ if ( shown ) { - gtk_widget_show( widget ); + widget.show(); } else { @@ -38,11 +38,11 @@ inline void widget_set_visible( GtkWidget* widget, bool shown ){ } } -inline bool widget_is_visible( GtkWidget* widget ){ +inline bool widget_is_visible( ui::Widget widget ){ return gtk_widget_get_visible( widget ) != FALSE; } -inline void widget_toggle_visible( GtkWidget* widget ){ +inline void widget_toggle_visible( ui::Widget widget ){ widget_set_visible( widget, !widget_is_visible( widget ) ); } @@ -76,17 +76,17 @@ bool m_shownDeferred; ToggleShown( const ToggleShown& other ); // NOT COPYABLE ToggleShown& operator=( const ToggleShown& other ); // NOT ASSIGNABLE -static gboolean notify_visible( GtkWidget* widget, gpointer dummy, ToggleShown* self ){ +static gboolean notify_visible( ui::Widget widget, gpointer dummy, ToggleShown* self ){ self->update(); return FALSE; } -static gboolean destroy( GtkWidget* widget, ToggleShown* self ){ +static gboolean destroy( ui::Widget widget, ToggleShown* self ){ self->m_shownDeferred = gtk_widget_get_visible( self->m_widget ) != FALSE; - self->m_widget = 0; + self->m_widget = ui::Widget(nullptr); return FALSE; } public: -GtkWidget* m_widget; +ui::Widget m_widget; ToggleItem m_item; ToggleShown( bool shown ) @@ -96,7 +96,7 @@ void update(){ m_item.update(); } bool active() const { - if ( m_widget == 0 ) { + if ( !m_widget ) { return m_shownDeferred; } else @@ -109,7 +109,7 @@ void exportActive( const BoolImportCallback& importCallback ){ } typedef MemberCaller1 ActiveCaller; void set( bool shown ){ - if ( m_widget == 0 ) { + if ( !m_widget ) { m_shownDeferred = shown; } else @@ -121,7 +121,7 @@ void toggle(){ widget_toggle_visible( m_widget ); } typedef MemberCaller ToggleCaller; -void connect( GtkWidget* widget ){ +void connect( ui::Widget 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 ); @@ -137,7 +137,7 @@ inline void widget_queue_draw( GtkWidget& widget ){ typedef ReferenceCaller WidgetQueueDrawCaller; -inline void widget_make_default( GtkWidget* widget ){ +inline void widget_make_default( ui::Widget widget ){ gtk_widget_set_can_default( widget, true ); gtk_widget_grab_default( widget ); } @@ -146,18 +146,18 @@ class WidgetFocusPrinter { const char* m_name; -static gboolean focus_in( GtkWidget *widget, GdkEventFocus *event, WidgetFocusPrinter* self ){ +static gboolean focus_in( ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter* self ){ globalOutputStream() << self->m_name << " takes focus\n"; return FALSE; } -static gboolean focus_out( GtkWidget *widget, GdkEventFocus *event, WidgetFocusPrinter* self ){ +static gboolean focus_out( ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter* self ){ globalOutputStream() << self->m_name << " loses focus\n"; return FALSE; } public: WidgetFocusPrinter( const char* name ) : m_name( name ){ } -void connect( GtkWidget* widget ){ +void connect( ui::Widget widget ){ g_signal_connect( G_OBJECT( widget ), "focus_in_event", G_CALLBACK( focus_in ), this ); g_signal_connect( G_OBJECT( widget ), "focus_out_event", G_CALLBACK( focus_out ), this ); } diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 97d5fc1c..86a0b139 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -769,7 +769,7 @@ ToggleShown g_camera_shown( true ); void CamWnd_setParent( CamWnd& camwnd, ui::Window parent ){ camwnd.m_parent = parent; - g_camera_shown.connect( GTK_WIDGET( camwnd.m_parent ) ); + g_camera_shown.connect( camwnd.m_parent ); } void CamWnd_Update( CamWnd& camwnd ){ diff --git a/radiant/commands.cpp b/radiant/commands.cpp index 840a570d..7874de24 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -477,9 +477,9 @@ public: gtk_widget_show( spacer ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( spacer ), TRUE, TRUE, 0 ); - GtkButton* button = create_modal_dialog_button( "Close", dialog.m_close_button ); + auto button = create_modal_dialog_button( "Close", dialog.m_close_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_grab_default( GTK_WIDGET( button ) ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); diff --git a/radiant/entitylist.cpp b/radiant/entitylist.cpp index 6ec2f55d..d6e2566b 100644 --- a/radiant/entitylist.cpp +++ b/radiant/entitylist.cpp @@ -245,7 +245,7 @@ void entitylist_treeview_row_expanded( GtkTreeView* view, GtkTreeIter* iter, Gtk void EntityList_SetShown( bool shown ){ - widget_set_visible( GTK_WIDGET( getEntityList().m_window ), shown ); + widget_set_visible( getEntityList().m_window, shown ); } void EntityList_toggleShown(){ diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index 7b954535..9c4a62a3 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -134,7 +134,7 @@ ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const S bool GroupDialog_isShown(){ - return widget_is_visible( GTK_WIDGET( g_GroupDlg.m_window ) ); + return widget_is_visible( g_GroupDlg.m_window ); } void GroupDialog_setShown( bool shown ){ shown ? g_GroupDlg.Show() : g_GroupDlg.Hide(); diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index 09e7bcc7..2f8c4121 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -393,9 +393,9 @@ void DoSides( int type, int axis ){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); + auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { @@ -661,9 +661,9 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { @@ -889,9 +889,9 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); } { @@ -957,9 +957,9 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, char* title ){ gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); } { @@ -1016,9 +1016,9 @@ EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 ); } { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); } } diff --git a/radiant/map.cpp b/radiant/map.cpp index ba9d4021..a4d8719a 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -2086,9 +2086,9 @@ void DoFind(){ GtkHBox* hbox = create_dialog_hbox( 4 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), TRUE, TRUE, 0 ); { - GtkButton* button = create_dialog_button( "Find", G_CALLBACK( dialog_button_ok ), &dialog ); + auto button = create_dialog_button( "Find", G_CALLBACK( dialog_button_ok ), &dialog ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index c2a8b627..1cf11d18 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -933,9 +933,9 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); + auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_grab_focus( GTK_WIDGET( button ) ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } @@ -1089,9 +1089,9 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); { - GtkButton* button = create_modal_dialog_button( "OK", ok_button ); + auto button = create_modal_dialog_button( "OK", ok_button ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE ); } { diff --git a/radiant/select.cpp b/radiant/select.cpp index 3f16a522..16241f31 100644 --- a/radiant/select.cpp +++ b/radiant/select.cpp @@ -984,9 +984,9 @@ void DoRotateDlg(){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkButton* button = create_dialog_button( "OK", G_CALLBACK( rotatedlg_ok ), &g_rotate_dialog ); + auto button = create_dialog_button( "OK", G_CALLBACK( rotatedlg_ok ), &g_rotate_dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { @@ -1129,9 +1129,9 @@ void DoScaleDlg(){ GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); { - GtkButton* button = create_dialog_button( "OK", G_CALLBACK( scaledlg_ok ), &g_scale_dialog ); + auto button = create_dialog_button( "OK", G_CALLBACK( scaledlg_ok ), &g_scale_dialog ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); + widget_make_default( button ); gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); } { diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 1d77da5b..a689e275 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -2539,19 +2539,19 @@ void ToggleShowGrid(){ ToggleShown g_xy_top_shown( true ); void XY_Top_Shown_Construct( ui::Window parent ){ - g_xy_top_shown.connect( GTK_WIDGET( parent ) ); + g_xy_top_shown.connect( parent ); } ToggleShown g_yz_side_shown( false ); void YZ_Side_Shown_Construct( ui::Window parent ){ - g_yz_side_shown.connect( GTK_WIDGET( parent ) ); + g_yz_side_shown.connect( parent ); } ToggleShown g_xz_front_shown( false ); void XZ_Front_Shown_Construct( ui::Window parent ){ - g_xz_front_shown.connect( GTK_WIDGET( parent ) ); + g_xz_front_shown.connect( parent ); } -- 2.39.2