]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/gtkdlgs.cpp
radiant/texwindow: test .wad file extension case-insensitively on all systems, fix...
[xonotic/netradiant.git] / radiant / gtkdlgs.cpp
index 9f07e893e5892de944477f464f7e51737bc0d66f..a8ec09724249e4eb70228484b7d14f04460a7aab 100644 (file)
@@ -40,7 +40,6 @@
 #include <gtk/gtk.h>
 
 #include "debugging/debugging.h"
-#include "version.h"
 #include "aboutmsg.h"
 
 #include "igl.h"
@@ -199,7 +198,7 @@ class ProjectSettingsDialog
 {
 public:
 GameCombo game_combo;
-GtkComboBox* gamemode_combo;
+ui::ComboBox gamemode_combo{ui::null};
 };
 
 ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, ModalDialog& modal ){
@@ -210,9 +209,7 @@ ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal
                window.add(table1);
                {
             auto vbox = create_dialog_vbox( 4 );
-                       gtk_table_attach( table1, vbox , 1, 2, 0, 1,
-                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                         (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+            table1.attach(vbox, {1, 2, 0, 1}, {GTK_FILL, GTK_FILL});
                        {
                 auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &modal );
                                vbox.pack_start( button, FALSE, FALSE, 0 );
@@ -224,9 +221,7 @@ ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal
                }
                {
                        auto frame = create_dialog_frame( "Project settings" );
-                       gtk_table_attach( table1, frame , 0, 1, 0, 1,
-                                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                         (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+            table1.attach(frame, {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
                        {
                                auto table2 = create_dialog_table( ( globalMappingMode().do_mapping_mode ) ? 4 : 3, 2, 4, 4, 4 );
                                frame.add(table2);
@@ -234,9 +229,7 @@ ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal
                                {
                                        auto label = ui::Label( "Select mod" );
                                        label.show();
-                                       gtk_table_attach( table2, label , 0, 1, 0, 1,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table2.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
                                        gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
                                }
                                {
@@ -249,9 +242,7 @@ ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal
                                        gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().custom );
 
                                        dialog.game_combo.game_select.show();
-                                       gtk_table_attach( table2, dialog.game_combo.game_select , 1, 2, 0, 1,
-                                                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table2.attach(dialog.game_combo.game_select, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
 
                                        dialog.game_combo.game_select.connect( "changed", G_CALLBACK( OnSelchangeComboWhatgame ), &dialog.game_combo );
                                }
@@ -259,17 +250,13 @@ ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal
                                {
                                        auto label = ui::Label( "fs_game" );
                                        label.show();
-                                       gtk_table_attach( table2, label , 0, 1, 1, 2,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table2.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
                                        gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
                                }
                                {
                                        auto entry = ui::Entry(ui::New);
                                        entry.show();
-                                       gtk_table_attach( table2, entry , 1, 2, 1, 2,
-                                                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table2.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
 
                                        dialog.game_combo.fsgame_entry = entry;
                                }
@@ -277,9 +264,7 @@ ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal
                                if ( globalMappingMode().do_mapping_mode ) {
                                        auto label = ui::Label( "Mapping mode" );
                                        label.show();
-                                       gtk_table_attach( table2, label , 0, 1, 3, 4,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table2.attach(label, {0, 1, 3, 4}, {GTK_FILL, 0});
                                        gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
 
                                        auto combo = ui::ComboBoxText(ui::New);
@@ -287,9 +272,7 @@ ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal
                                        gtk_combo_box_text_append_text( combo, globalMappingMode().mp_mapping_mode );
 
                                        combo.show();
-                                       gtk_table_attach( table2, combo , 1, 2, 3, 4,
-                                                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table2.attach(combo, {1, 2, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
 
                                        dialog.gamemode_combo = combo;
                                }
@@ -369,13 +352,13 @@ void DoProjectSettings(){
 
 void DoSides( int type, int axis ){
        ModalDialog dialog;
-       GtkEntry* sides_entry;
 
        auto window = MainFrame_getWindow().create_dialog_window("Arbitrary sides", G_CALLBACK(dialog_delete_callback ), &dialog );
 
        auto accel = ui::AccelGroup(ui::New);
        window.add_accel_group( accel );
 
+       auto sides_entry = ui::Entry(ui::New);
        {
                auto hbox = create_dialog_hbox( 4, 4 );
                window.add(hbox);
@@ -385,10 +368,9 @@ void DoSides( int type, int axis ){
                        hbox.pack_start( label, FALSE, FALSE, 0 );
                }
                {
-                       auto entry = ui::Entry(ui::New);
+                       auto entry = sides_entry;
                        entry.show();
                        hbox.pack_start( entry, FALSE, FALSE, 0 );
-                       sides_entry = entry;
                        gtk_widget_grab_focus( entry  );
                }
                {
@@ -432,7 +414,7 @@ void about_button_credits( ui::Widget widget, gpointer data ){
        OpenURL( cred.c_str() );
 }
 
-void about_button_issues( GtkWidget *widget, gpointer data ){
+void about_button_issues( ui::Widget widget, gpointer data ){
        StringOutputStream cred( 256 );
        cred << "https://gitlab.com/xonotic/netradiant/issues";
        OpenURL( cred.c_str() );
@@ -442,7 +424,7 @@ void DoAbout(){
        ModalDialog dialog;
        ModalDialogButton ok_button( dialog, eIDOK );
 
-       auto window = MainFrame_getWindow().create_modal_dialog_window("About NetRadiant", dialog );
+       auto window = MainFrame_getWindow().create_modal_dialog_window("About " RADIANT_NAME, dialog );
 
        {
                auto vbox = create_dialog_vbox( 4, 4 );
@@ -454,7 +436,7 @@ void DoAbout(){
 
                        {
                 auto vbox2 = create_dialog_vbox( 4 );
-                               hbox.pack_start( vbox2, TRUE, FALSE, 0 );
+                               hbox.pack_start( vbox2, FALSE, FALSE, 5 );
                                {
                                        auto frame = create_dialog_frame( 0, ui::Shadow::IN );
                                        vbox2.pack_start( frame, FALSE, FALSE, 0 );
@@ -467,26 +449,30 @@ void DoAbout(){
                        }
 
                        {
-                               char const *label_text = "NetRadiant " RADIANT_VERSION "\n"
-                                                                               __DATE__ "\n\n"
-                                        RADIANT_ABOUTMSG "\n\n"
-                                                                               "This program is free software\n"
-                                                                               "licensed under the GNU GPL.\n\n"
-                                                                               "NetRadiant is unsupported, however\n"
-                                                                               "you may report your problems at\n"
-                                                                               "https://gitlab.com/xonotic/netradiant/issues";
+                               char const *label_text = RADIANT_NAME " " RADIANT_VERSION_STRING " (" __DATE__ ")\n"
+                                                                               RADIANT_ABOUTMSG "\n\n"
+                                                                               "Get news and updates on "
+                                                                               "<a href='https://netradiant.gitlab.io/'>"
+                                                                                       "netradiant.gitlab.io"
+                                                                               "</a>\n"
+                                                                               "Please report your issues on "
+                                                                               "<a href='https://gitlab.com/xonotic/netradiant/issues'>"
+                                                                                       "gitlab.com/xonotic/netradiant/issues"
+                                                                               "</a>\n\n"
+                                                                               "This program is free software licensed under the GNU GPL.";
 
                                auto label = ui::Label( label_text );
+                               gtk_label_set_use_markup( GTK_LABEL( label ), true );
 
                                label.show();
-                               hbox.pack_start( label, FALSE, FALSE, 0 );
-                               gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
+                               hbox.pack_start( label, TRUE, TRUE, 0 );
+                               gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
                                gtk_label_set_justify( label, GTK_JUSTIFY_LEFT );
                        }
 
                        {
                 auto vbox2 = create_dialog_vbox( 4 );
-                               hbox.pack_start( vbox2, FALSE, TRUE, 0 );
+                               hbox.pack_start( vbox2, TRUE, TRUE, 0 );
                                {
                     auto button = create_modal_dialog_button( "OK", ok_button );
                                        vbox2.pack_start( button, FALSE, FALSE, 0 );
@@ -514,49 +500,37 @@ void DoAbout(){
                                {
                                        auto label = ui::Label( "Vendor:" );
                                        label.show();
-                                       gtk_table_attach( table, label , 0, 1, 0, 1,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
                                        gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
                                }
                                {
                                        auto label = ui::Label( "Version:" );
                                        label.show();
-                                       gtk_table_attach( table, label , 0, 1, 1, 2,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
                                        gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
                                }
                                {
                                        auto label = ui::Label( "Renderer:" );
                                        label.show();
-                                       gtk_table_attach( table, label , 0, 1, 2, 3,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {0, 1, 2, 3}, {GTK_FILL, 0});
                                        gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
                                }
                                {
                                        auto label = ui::Label( reinterpret_cast<const char*>( glGetString( GL_VENDOR ) ) );
                                        label.show();
-                                       gtk_table_attach( table, label , 1, 2, 0, 1,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {1, 2, 0, 1}, {GTK_FILL, 0});
                                        gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
                                }
                                {
                                        auto label = ui::Label( reinterpret_cast<const char*>( glGetString( GL_VERSION ) ) );
                                        label.show();
-                                       gtk_table_attach( table, label , 1, 2, 1, 2,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {1, 2, 1, 2}, {GTK_FILL, 0});
                                        gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
                                }
                                {
                                        auto label = ui::Label( reinterpret_cast<const char*>( glGetString( GL_RENDERER ) ) );
                                        label.show();
-                                       gtk_table_attach( table, label , 1, 2, 2, 3,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {1, 2, 2, 3}, {GTK_FILL, 0});
                                        gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
                                }
                        }
@@ -625,34 +599,26 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){
                                {
                                        auto label = ui::Label( "Texture x:" );
                                        label.show();
-                                       gtk_table_attach( table, label , 0, 1, 0, 1,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
                                        gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
                                }
                                {
                                        auto label = ui::Label( "Texture y:" );
                                        label.show();
-                                       gtk_table_attach( table, label , 0, 1, 1, 2,
-                                                                         (GtkAttachOptions) ( GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
                                        gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
                                }
                                {
                                        auto entry = ui::Entry(ui::New);
                                        entry.show();
-                                       gtk_table_attach( table, entry , 1, 2, 0, 1,
-                                                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
 
                                        x = entry;
                                }
                                {
                                        auto entry = ui::Entry(ui::New);
                                        entry.show();
-                                       gtk_table_attach( table, entry , 1, 2, 1, 2,
-                                                                         (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+                    table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
 
                                        y = entry;
                                }
@@ -710,7 +676,7 @@ static ui::Window text_editor{ui::null};
 static ui::Widget text_widget{ui::null}; // slave, text widget from the gtk editor
 
 static gint editor_delete( ui::Widget widget, gpointer data ){
-       if ( widget.window().alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
+       if ( ui::alert( widget.window(), "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
                return TRUE;
        }
 
@@ -724,7 +690,7 @@ static void editor_save( ui::Widget widget, gpointer data ){
        gpointer text = g_object_get_data( G_OBJECT( data ), "text" );
 
        if ( f == 0 ) {
-               ui::Widget::from(data).window().alert( "Error saving file !" );
+               ui::alert( ui::Widget::from(data).window(), "Error saving file !" );
                return;
        }
 
@@ -734,7 +700,7 @@ static void editor_save( ui::Widget widget, gpointer data ){
 }
 
 static void editor_close( ui::Widget widget, gpointer data ){
-       if ( text_editor.window().alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
+       if ( ui::alert( text_editor.window(), "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
                return;
        }
 
@@ -774,14 +740,14 @@ static void CreateGtkTextEditor(){
        hbox.pack_end(button, FALSE, FALSE, 0);
        button.connect( "clicked",
                                          G_CALLBACK( editor_close ), dlg );
-       gtk_widget_set_size_request( button, 60, -1 );
+       button.dimensions(60, -1);
 
        button = ui::Button( "Save" );
        button.show();
        hbox.pack_end(button, FALSE, FALSE, 0);
        button.connect( "clicked",
                                          G_CALLBACK( editor_save ), dlg );
-       gtk_widget_set_size_request( button, 60, -1 );
+       button.dimensions(60, -1);
 
        text_editor = dlg;
        text_widget = text;
@@ -811,7 +777,7 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos ){
 
                gtk_window_set_title( text_editor, filename );
 
-               GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(ui::TextView::from(text_widget));
+               auto text_buffer = gtk_text_view_get_buffer(ui::TextView::from(text_widget));
                gtk_text_buffer_set_text( text_buffer, (char*)buf, len );
 
                old_filename = g_object_get_data( G_OBJECT( text_editor ), "filename" );
@@ -919,7 +885,6 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){
 
 EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, const char* title ){
        ModalDialog dialog;
-       GtkEntry* textentry;
        ModalDialogButton ok_button( dialog, eIDOK );
        ModalDialogButton cancel_button( dialog, eIDCANCEL );
 
@@ -928,6 +893,7 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, const char* title ){
        auto accel_group = ui::AccelGroup(ui::New);
        window.add_accel_group( accel_group );
 
+       auto textentry = ui::Entry(ui::New);
        {
                auto hbox = create_dialog_hbox( 4, 4 );
                window.add(hbox);
@@ -941,13 +907,11 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, const char* title ){
                                vbox.pack_start( label, FALSE, FALSE, 0 );
                        }
                        {
-                               auto entry = ui::Entry(ui::New);
+                               auto entry = textentry;
                                entry.show();
                                vbox.pack_start( entry, TRUE, TRUE, 0 );
 
                                gtk_widget_grab_focus( entry  );
-
-                               textentry = entry;
                        }
                }
                {