From: TimePath Date: Fri, 21 Jul 2017 15:33:39 +0000 (+1000) Subject: Wrap gtkutil/nonmodal X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ce924360c77947709161dd05877bd079a0704b8f;p=xonotic%2Fnetradiant.git Wrap gtkutil/nonmodal --- diff --git a/libs/gtkutil/dialog.h b/libs/gtkutil/dialog.h index 1bf6c0a0..3fbb14b1 100644 --- a/libs/gtkutil/dialog.h +++ b/libs/gtkutil/dialog.h @@ -108,7 +108,7 @@ class PathEntry { public: GtkFrame* m_frame; -GtkEntry* m_entry; +ui::Entry m_entry; GtkButton* m_button; PathEntry( GtkFrame* frame, GtkEntry* entry, GtkButton* button ) : m_frame( frame ), diff --git a/libs/gtkutil/nonmodal.h b/libs/gtkutil/nonmodal.h index b8dc3f86..98f05b1b 100644 --- a/libs/gtkutil/nonmodal.h +++ b/libs/gtkutil/nonmodal.h @@ -30,10 +30,7 @@ #include "pointer.h" #include "button.h" -typedef struct _GtkEntry GtkEntry; - - -inline gboolean escape_clear_focus_widget( GtkWidget* widget, GdkEventKey* event, gpointer data ){ +inline gboolean escape_clear_focus_widget( ui::Widget widget, GdkEventKey* event, gpointer data ){ if ( event->keyval == GDK_KEY_Escape ) { gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), NULL ); return TRUE; @@ -41,7 +38,7 @@ inline gboolean escape_clear_focus_widget( GtkWidget* widget, GdkEventKey* event return FALSE; } -inline void widget_connect_escape_clear_focus_widget( GtkWidget* widget ){ +inline void widget_connect_escape_clear_focus_widget( ui::Widget widget ){ g_signal_connect( G_OBJECT( widget ), "key_press_event", G_CALLBACK( escape_clear_focus_widget ), 0 ); } @@ -52,12 +49,12 @@ bool m_editing; Callback m_apply; Callback m_cancel; -static gboolean focus_in( GtkEntry* entry, GdkEventFocus *event, NonModalEntry* self ){ +static gboolean focus_in( ui::Entry entry, GdkEventFocus *event, NonModalEntry* self ){ self->m_editing = false; return FALSE; } -static gboolean focus_out( GtkEntry* entry, GdkEventFocus *event, NonModalEntry* self ){ +static gboolean focus_out( ui::Entry entry, GdkEventFocus *event, NonModalEntry* self ){ if ( self->m_editing && gtk_widget_get_visible( GTK_WIDGET(entry) ) ) { self->m_apply(); } @@ -65,12 +62,12 @@ static gboolean focus_out( GtkEntry* entry, GdkEventFocus *event, NonModalEntry* return FALSE; } -static gboolean changed( GtkEntry* entry, NonModalEntry* self ){ +static gboolean changed( ui::Entry entry, NonModalEntry* self ){ self->m_editing = true; return FALSE; } -static gboolean enter( GtkEntry* entry, GdkEventKey* event, NonModalEntry* self ){ +static gboolean enter( ui::Entry entry, GdkEventKey* event, NonModalEntry* self ){ if ( event->keyval == GDK_Return ) { self->m_apply(); self->m_editing = false; @@ -80,7 +77,7 @@ static gboolean enter( GtkEntry* entry, GdkEventKey* event, NonModalEntry* self return FALSE; } -static gboolean escape( GtkEntry* entry, GdkEventKey* event, NonModalEntry* self ){ +static gboolean escape( ui::Entry entry, GdkEventKey* event, NonModalEntry* self ){ if ( event->keyval == GDK_Escape ) { self->m_cancel(); self->m_editing = false; @@ -93,7 +90,7 @@ static gboolean escape( GtkEntry* entry, GdkEventKey* event, NonModalEntry* self public: NonModalEntry( const Callback& apply, const Callback& cancel ) : m_editing( false ), m_apply( apply ), m_cancel( cancel ){ } -void connect( GtkEntry* entry ){ +void connect( ui::Entry entry ){ g_signal_connect( G_OBJECT( entry ), "focus_in_event", G_CALLBACK( focus_in ), this ); g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( focus_out ), this ); g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( enter ), this ); @@ -108,12 +105,12 @@ class NonModalSpinner Callback m_apply; Callback m_cancel; -static gboolean changed( GtkSpinButton* spin, NonModalSpinner* self ){ +static gboolean changed( ui::SpinButton spin, NonModalSpinner* self ){ self->m_apply(); return FALSE; } -static gboolean enter( GtkSpinButton* spin, GdkEventKey* event, NonModalSpinner* self ){ +static gboolean enter( ui::SpinButton spin, GdkEventKey* event, NonModalSpinner* self ){ if ( event->keyval == GDK_Return ) { gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( spin ) ) ), NULL ); return TRUE; @@ -121,7 +118,7 @@ static gboolean enter( GtkSpinButton* spin, GdkEventKey* event, NonModalSpinner* return FALSE; } -static gboolean escape( GtkSpinButton* spin, GdkEventKey* event, NonModalSpinner* self ){ +static gboolean escape( ui::SpinButton spin, GdkEventKey* event, NonModalSpinner* self ){ if ( event->keyval == GDK_Escape ) { self->m_cancel(); gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( spin ) ) ), NULL ); @@ -133,7 +130,7 @@ static gboolean escape( GtkSpinButton* spin, GdkEventKey* event, NonModalSpinner public: NonModalSpinner( const Callback& apply, const Callback& cancel ) : m_apply( apply ), m_cancel( cancel ){ } -void connect( GtkSpinButton* spin ){ +void connect( ui::SpinButton spin ){ guint handler = g_signal_connect( G_OBJECT( gtk_spin_button_get_adjustment( spin ) ), "value_changed", G_CALLBACK( changed ), this ); g_object_set_data( G_OBJECT( spin ), "handler", gint_to_pointer( handler ) ); g_signal_connect( G_OBJECT( spin ), "key_press_event", G_CALLBACK( enter ), this ); @@ -149,7 +146,7 @@ Callback m_changed; public: NonModalRadio( const Callback& changed ) : m_changed( changed ){ } -void connect( GtkRadioButton* radio ){ +void connect( ui::RadioButton radio ){ GSList* group = gtk_radio_button_get_group( radio ); for (; group != 0; group = g_slist_next( group ) ) { diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 42b21256..389e92fd 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -160,12 +160,12 @@ typedef MemberCaller UpdateCaller; class StringAttribute : public EntityAttribute { CopiedString m_key; -GtkEntry* m_entry; +ui::Entry m_entry; NonModalEntry m_nonModal; public: StringAttribute( const char* key ) : m_key( key ), - m_entry( 0 ), + m_entry( nullptr ), m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){ auto entry = ui::Entry(); gtk_widget_show( GTK_WIDGET( entry ) ); diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index 3a00ace5..0a1ed262 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -626,17 +626,17 @@ ui::Window SurfaceInspector::BuildDialog(){ gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); { ui::Widget label = ui::Label( "Horizontal shift" ); - gtk_widget_show( label ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); m_hshiftIncrement.m_spin = spin; m_hshiftSpinner.connect( spin ); - gtk_widget_show( GTK_WIDGET( spin ) ); + spin.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -644,7 +644,7 @@ ui::Window SurfaceInspector::BuildDialog(){ } { ui::Widget label = ui::Label( "Step" ); - gtk_widget_show( label ); + label.show(); gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, (GtkAttachOptions) ( GTK_FILL ), @@ -652,7 +652,7 @@ ui::Window SurfaceInspector::BuildDialog(){ } { auto entry = ui::Entry(); - gtk_widget_show( GTK_WIDGET( entry ) ); + entry.show(); gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); @@ -669,7 +669,7 @@ ui::Window SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); m_vshiftIncrement.m_spin = spin; m_vshiftSpinner.connect( spin ); gtk_widget_show( GTK_WIDGET( spin ) ); @@ -705,7 +705,7 @@ ui::Window SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 5 ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 5 ); m_hscaleIncrement.m_spin = spin; m_hscaleSpinner.connect( spin ); gtk_widget_show( GTK_WIDGET( spin ) ); @@ -741,7 +741,7 @@ ui::Window SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 5 ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 5 ); m_vscaleIncrement.m_spin = spin; m_vscaleSpinner.connect( spin ); gtk_widget_show( GTK_WIDGET( spin ) ); @@ -777,7 +777,7 @@ ui::Window SurfaceInspector::BuildDialog(){ (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); + auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 ); m_rotateIncrement.m_spin = spin; m_rotateSpinner.connect( spin ); gtk_widget_show( GTK_WIDGET( spin ) );