What to do?
You shouldn't use
sudo for graphical applications, such as
What's causing the error
I'm not sure. Apparently, the reason of error you get is that
gedit is trying to invoke
SessionManager's Inhibit method via D-bus.
If normal applications can connect to dbus, they should have some config files in
/usr/share/dbus-1. I expected them to be
/usr/share/dbus-1/system-services/org.gnome.SessionManager.service. On my Debian machine I can't find any of them.
So, my guess is
gnome-session doesn't need a dbus
.session file as it's not a normal application. In fact, it is itself responsible for starting the per-session instance of dbus. But the per-session instance of dbus is in fact per-user per-session, so it can't interact with graphical application running under different user than you (and root user, running
sudo gedit, is different than you).