]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Wrap gtkutil/nonmodal
authorTimePath <andrew.hardaker1995@gmail.com>
Fri, 21 Jul 2017 15:33:39 +0000 (01:33 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 31 Jul 2017 12:35:47 +0000 (22:35 +1000)
libs/gtkutil/dialog.h
libs/gtkutil/nonmodal.h
radiant/entityinspector.cpp
radiant/surfacedialog.cpp

index 1bf6c0a0cb3268e9b9966610a02988258f551651..3fbb14b1163bafd8e86d9404bfeaa2b58d6c7b35 100644 (file)
@@ -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 ),
index b8dc3f861e049f4cc2295ba6bdb05fcfae39fb14..98f05b1b0c23fa54c130112362dadf556ce27c17 100644 (file)
 #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 ) )
        {
index 42b21256aecb4bc8cce9d20542069139c31f665e..389e92fd44b166c4f038ee6282c0ba3f30d96a80 100644 (file)
@@ -160,12 +160,12 @@ typedef MemberCaller<BooleanAttribute, &BooleanAttribute::update> 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 ) );
index 3a00ace5e9177f8252dd6aa856a3c91eb4aec37e..0a1ed2622e95bf9008d98d37e7c4e06ec4ebcd97 100644 (file)
@@ -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 ) );