From: Thomas Debesse Date: Mon, 20 Jun 2022 02:51:00 +0000 (+0200) Subject: Merge commit 'ff48e71434a414958e6e56628ccf04284d030784' into master-merge X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2ce2d42b275b2a710227b375e495a817799fe2a6;p=xonotic%2Fnetradiant.git Merge commit 'ff48e71434a414958e6e56628ccf04284d030784' into master-merge --- 2ce2d42b275b2a710227b375e495a817799fe2a6 diff --cc radiant/main.cpp index 8564fc7b,88cd0cad..a2d288f1 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@@ -502,23 -534,32 +502,48 @@@ void user_shortcuts_save() SaveCommandMap( path.c_str() ); } + void add_local_rc_files(){ + #define GARUX_DISABLE_GTKTHEME + #ifndef GARUX_DISABLE_GTKTHEME + /* FIXME: HACK: not GTK3 compatible + https://developer.gnome.org/gtk2/stable/gtk2-Resource-Files.html#gtk-rc-add-default-file + https://developer.gnome.org/gtk3/stable/gtk3-Resource-Files.html#gtk-rc-add-default-file + > gtk_rc_add_default_file has been deprecated since version 3.0 and should not be used in newly-written code. + > Use GtkStyleContext with a custom GtkStyleProvider instead + */ + + { + StringOutputStream path( 512 ); + path << AppPath_get() << ".gtkrc-2.0.radiant"; + gtk_rc_add_default_file( path.c_str() ); + } + #ifdef WIN32 + { + StringOutputStream path( 512 ); + path << AppPath_get() << ".gtkrc-2.0.win"; + gtk_rc_add_default_file( path.c_str() ); + } + #endif + #endif // GARUX_DISABLE_GTKTHEME + } + +/* HACK: If ui::main is not called yet, +gtk_main_quit will not quit, so tell main +to not call ui::main. This happens when a +map is loaded from command line and require +a restart because of wrong format. +Delete this when the code to not have to +restart to load another format is merged. */ +bool g_dontStart = false; + int main( int argc, char* argv[] ){ +#if GTK_TARGET == 3 + // HACK: force legacy GL backend as we don't support GL3 yet + setenv("GDK_GL", "LEGACY", 0); +#if GDEF_OS_LINUX || GDEF_OS_BSD + setenv("GDK_BACKEND", "x11", 0); +#endif +#endif // GTK_TARGET == 3 crt_init(); streams_init(); @@@ -561,23 -596,18 +586,23 @@@ } // Gtk already removed parsed `--options` - if ( argc == 2 ) { - if ( strlen( argv[ 1 ] ) > 1 ) { - mapname = argv[ 1 ]; + if (argc == 2) { + if ( strlen( argv[1] ) > 1 ) { - if ( g_str_has_suffix( argv[1], ".map" ) ) { - if ( g_path_is_absolute( argv[1] ) ) { + mapname = argv[1]; + + if ( g_str_has_suffix( mapname, ".map" ) ) { + if ( !g_path_is_absolute( mapname ) ) { + mapname = g_build_filename( g_get_current_dir(), mapname, NULL ); } - else { - mapname = g_build_filename( g_get_current_dir(), argv[1], NULL ); - } + +#if GDEF_OS_WINDOWS + mapname_buffer << PathCleaned( mapname ); + mapname = mapname_buffer.c_str(); +#endif } else { - g_print( "bad file name, will not load: %s\n", argv[1] ); + g_print( "bad file name, will not load: %s\n", mapname ); + mapname = NULL; } } } @@@ -604,6 -634,12 +629,8 @@@ paths_init(); + add_local_rc_files(); + - if ( !check_version() ) { - return EXIT_FAILURE; - } - show_splash(); create_global_pid(); @@@ -663,17 -699,7 +690,17 @@@ remove_local_pid(); + /* HACK: If ui::main is not called yet, + gtk_main_quit will not quit, so tell main + to not call ui::main. This happens when a + map is loaded from command line and require + a restart because of wrong format. + Delete this when the code to not have to + restart to load another format is merged. */ + if ( !g_dontStart ) + { - ui::main(); + ui::main(); + } // avoid saving prefs when the app is minimized if ( g_pParentWnd->IsSleeping() ) { diff --cc radiant/mainframe.cpp index c4137081,38c46faf..8cc59bc1 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@@ -102,19 -102,12 +102,24 @@@ #include "texwindow.h" #include "filterbar.h" +#if GDEF_OS_WINDOWS +#include +#else +#include +#endif + +#ifdef WORKAROUND_WINDOWS_GTK2_GLWIDGET +/* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ +#define WORKAROUND_GOBJECT_SET_GLWIDGET(window, widget) g_object_set_data( G_OBJECT( window ), "glwidget", G_OBJECT( widget ) ) +#else +#define WORKAROUND_GOBJECT_SET_GLWIDGET(window, widget) +#endif + + #define GARUX_DISABLE_GTKTHEME + #ifndef GARUX_DISABLE_GTKTHEME + #include "gtktheme.h" + #endif + - struct layout_globals_t { WindowPosition m_position; @@@ -1135,8 -1068,11 +1140,12 @@@ ui::MenuItem create_colours_menu() create_menu_item_with_mnemonic( menu_3, "Q3Radiant Original", "ColorSchemeQER" ); create_menu_item_with_mnemonic( menu_3, "Black and Green", "ColorSchemeBlackAndGreen" ); create_menu_item_with_mnemonic( menu_3, "Maya/Max/Lightwave Emulation", "ColorSchemeYdnar" ); + create_menu_item_with_mnemonic(menu_3, "Adwaita Dark", "ColorSchemeAdwaitaDark"); + #ifndef GARUX_DISABLE_GTKTHEME + create_menu_item_with_mnemonic( menu_in_menu, "GTK Theme...", "gtkThemeDlg" ); + #endif + menu_separator( menu_in_menu ); create_menu_item_with_mnemonic( menu_in_menu, "_Texture Background...", "ChooseTextureBackgroundColor" );