Wrap gtkutil/widget
authorTimePath <andrew.hardaker1995@gmail.com>
Fri, 21 Jul 2017 15:49:35 +0000 (01:49 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 31 Jul 2017 12:35:47 +0000 (22:35 +1000)
libs/gtkutil/messagebox.cpp
libs/gtkutil/widget.h
radiant/camwindow.cpp
radiant/commands.cpp
radiant/entitylist.cpp
radiant/groupdialog.cpp
radiant/gtkdlgs.cpp
radiant/map.cpp
radiant/patchmanip.cpp
radiant/select.cpp
radiant/xywindow.cpp

index 8930145..86ed48c 100644 (file)
@@ -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 ) );
                }
 
index bf84eef..77938c6 100644 (file)
@@ -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<ToggleShown, const BoolImportCallback&, &ToggleShown::exportActive> 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<ToggleShown, &ToggleShown::toggle> 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<GtkWidget, widget_queue_draw> 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 );
 }
index 97d5fc1..86a0b13 100644 (file)
@@ -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 ){
index 840a570..7874de2 100644 (file)
@@ -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 );
index 6ec2f55..d6e2566 100644 (file)
@@ -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(){
index 7b95453..9c4a62a 100644 (file)
@@ -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();
index 09e7bcc..2f8c412 100644 (file)
@@ -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 );
                        }
                }
index ba9d402..a4d8719 100644 (file)
@@ -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 );
                        }
                        {
index c2a8b62..1cf11d1 100644 (file)
@@ -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 );
                        }
                        {
index 3f16a52..16241f3 100644 (file)
@@ -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 );
                                }
                                {
index 1d77da5..a689e27 100644 (file)
@@ -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 );
 }