adding global variable to keep track if gtkmain has been called

When embedding plot creation in gtk (see example below)
The mainloop does not call `Gtk.main()` because it has been called by the embedder.

But `Gtk.main_quit()` is called depending on `is_interactive()`, it doesn't take in count who called `Gtk.main()` 

This causes that the embedder program, gets destroyed when destroying the last window of the plots.

The proposed solution is just an ugly variable added to keep track if `Gtk.main()` was called inside the mainloop to restrict  the call of `Gtk.main_quit()` 

This may be related to PR https://github.com/matplotlib/matplotlib/pull/2503
````
import matplotlib
matplotlib.use('GTK3AGG')
import matplotlib.pyplot as plt

from gi.repository import Gtk

class MyWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="Hello World")
        self.button = Gtk.Button(label="Click Here")
        self.button.connect("clicked", self.on_button_clicked)
        self.add(self.button)

    def on_button_clicked(self, widget):
        fig = plt.figure()
        ax = fig.add_subplot(111)
        ax.plot([1,2,3])
        plt.show()

win = MyWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
````