Okay, I figured it out.
To get this cool gnome bar in glade without having one of the aforementioned issues follow these steps:
Note that something like
main_win->set_titlebar(*header_bar); isn't even needed. There's nothing specific that you have to do in your code to make this work.
It seems the only way to maintain compatibility is the way already described in the question post. The best way to determine if gnome-shell is running or if the right version of GTK+ is used is the one below. (Or at least the best one I came up with). It uses the function
exec from here: stackoverflow.
std::string gnomeString = exec("echo \"$GDMSESSION|$XDG_CURRENT_DESKTOP\""); //optional requirement for gnome-like header bar: bool isGnome = gnomeString == "gnome|GNOME\n" || gnomeString == "gnome-shell|GNOME\n"; //absolute requirement for gnome-like header bar: bool correctGTKversion = gtk_major_version >= 3 && gtk_minor_version >= 10; std::cout << "isGnome: " << (isGnome?"yes":"no") << "\n"; std::cout << "correctGTK+: " << (correctGTKversion?"yes":"no") << "\n";