]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/gtkutil/dialog.cpp
Fix GTK_CRITICAL errors
[xonotic/netradiant.git] / libs / gtkutil / dialog.cpp
index 8fa34e657ea7acc4ef1340effa18d542161edebf..66470543c48e307c5e0573721c4e90cccac410f9 100644 (file)
@@ -58,7 +58,7 @@ ui::Table create_dialog_table( unsigned int rows, unsigned int columns, unsigned
 
 ui::Button create_dialog_button( const char* label, GCallback func, gpointer data ){
        auto button = ui::Button( label );
-       gtk_widget_set_size_request( GTK_WIDGET( button ), 64, -1 );
+       button.dimensions(64, -1);
        button.show();
        button.connect( "clicked", func, data );
        return button;
@@ -86,8 +86,9 @@ gboolean modal_dialog_delete( ui::Widget widget, GdkEvent* event, ModalDialog* d
 }
 
 EMessageBoxReturn modal_dialog_show( ui::Window window, ModalDialog& dialog ){
-       gtk_grab_add( GTK_WIDGET( window ) );
        window.show();
+       g_assert( GTK_IS_WINDOW(window) );
+       gtk_grab_add( GTK_WIDGET(window) );
 
        dialog.loop = true;
        while ( dialog.loop )
@@ -96,7 +97,7 @@ EMessageBoxReturn modal_dialog_show( ui::Window window, ModalDialog& dialog ){
        }
 
        window.hide();
-       gtk_grab_remove( GTK_WIDGET( window ) );
+       gtk_grab_remove( window  );
 
        return dialog.ret;
 }
@@ -118,11 +119,11 @@ ui::Window create_fixedsize_modal_dialog_window( ui::Window parent, const char*
 
        window_remove_minmax( window );
 
-       //gtk_widget_set_size_request(GTK_WIDGET(window), width, height);
+       //window.dimensions(width, height);
        //gtk_window_set_default_size(window, width, height);
        //gtk_window_resize(window, width, height);
        //GdkGeometry geometry = { width, height, -1, -1, width, height, -1, -1, -1, -1, GDK_GRAVITY_STATIC, };
-       //gtk_window_set_geometry_hints(window, GTK_WIDGET(window), &geometry, (GdkWindowHints)(GDK_HINT_POS|GDK_HINT_MIN_SIZE|GDK_HINT_BASE_SIZE));
+       //gtk_window_set_geometry_hints(window, window, &geometry, (GdkWindowHints)(GDK_HINT_POS|GDK_HINT_MIN_SIZE|GDK_HINT_BASE_SIZE));
 
        return window;
 }
@@ -183,7 +184,7 @@ RadioHBox RadioHBox_new( StringArrayRange names ){
        auto radio = ui::RadioButton(ui::null);
        for ( StringArrayRange::Iterator i = names.first; i != names.last; ++i )
        {
-               radio = ui::RadioButton(GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( group, *i ) ));
+               radio = ui::RadioButton::from( gtk_radio_button_new_with_label( group, *i ) );
                radio.show();
                hbox.pack_start( radio, FALSE, FALSE, 0 );
 
@@ -210,7 +211,7 @@ PathEntry PathEntry_new(){
 
        // browse button
        auto button = ui::Button(ui::New);
-       button_set_icon( button, "ellipsis.bmp" );
+       button_set_icon( button, "ellipsis.png" );
        button.show();
        hbox.pack_end(button, FALSE, FALSE, 0);
 
@@ -222,7 +223,7 @@ PathEntry PathEntry_new(){
 void PathEntry_setPath( PathEntry& self, const char* path ){
        gtk_entry_set_text( self.m_entry, path );
 }
-typedef ReferenceCaller1<PathEntry, const char*, PathEntry_setPath> PathEntrySetPathCaller;
+typedef ReferenceCaller<PathEntry, void(const char*), PathEntry_setPath> PathEntrySetPathCaller;
 
 void BrowsedPathEntry_clicked( ui::Widget widget, BrowsedPathEntry* self ){
        self->m_browse( PathEntrySetPathCaller( self->m_entry ) );
@@ -251,17 +252,13 @@ ui::Table DialogRow_new( const char* name, ui::Widget widget ){
        gtk_table_set_col_spacings( table, 4 );
        gtk_table_set_row_spacings( table, 0 );
 
-       gtk_table_attach( table, GTK_WIDGET( DialogLabel_new( name ) ), 0, 1, 0, 1,
-                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+    table.attach(DialogLabel_new(name), {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
 
-       gtk_table_attach( table, widget, 1, 3, 0, 1,
-                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+    table.attach(widget, {1, 3, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
 
        return table;
 }
 
-void DialogVBox_packRow( ui::VBox vbox, ui::Widget row ){
+void DialogVBox_packRow( ui::Box vbox, ui::Widget row ){
        vbox.pack_start( row, FALSE, FALSE, 0 );
 }