title: How to access GTKMM widgets from other file?
body: <p>I have a simple gtk+ application made with gtkmm, and I want to change the content of the window when I press a button, and I want to put that code in a seperate file (changeTitle.cc). How do I access the "buttons" object from that file? </p>
  
  <p>main.cc:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "buttons.h"
  #include &lt;gtkmm/application.h&gt;
  
  int main(int argc, char *argv[])
  {
  Glib::RefPtr&lt;Gtk::Application&gt; app =
  Gtk::Application::create(argc, argv,
    "org.gtkmm.examples.base");
  
  Buttons buttons;
  
  
  return app-&gt;run(buttons);
  
  }
  </code></pre>
  
  <p>buttons.h:</p>
  
  <pre><code>#ifndef GTKMM_EXAMPLE_BUTTONS_H
  #define GTKMM_EXAMPLE_BUTTONS_H
  
  #include &lt;gtkmm/window.h&gt;
  #include &lt;gtkmm/button.h&gt;
  #include &lt;gtkmm/box.h&gt;
  
  class Buttons : public Gtk::Window
  {
  public:
  Buttons();
  
  virtual ~Buttons();
  
  protected:
  //Signal handlers:
  void on_button_clicked();
  
  //Child widgets:
  Gtk::Button m_button;
  Gtk::Box buttonBox;
  };
  
  #endif //GTKMM_EXAMPLE_BUTTONS_H  
  </code></pre>
  
  <p>buttons.cc:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdlib.h&gt;
  #include "buttons.h"
  #include "changeTitle.h"
  
  Buttons::Buttons()
  {
  m_button.add_pixlabel("info.xpm", "click here");
  
  set_title("Menu");
  set_border_width(10);
  
  m_button.signal_clicked().connect( sigc::mem_fun(*this,
            &amp;Buttons::on_button_clicked) );
  
  add(buttonBox);
  
  buttonBox.pack_start(m_button);
  
  show_all_children();
  }
  
  Buttons::~Buttons()
  {
  
  }
  
  void Buttons::on_button_clicked()
  {
  changeTitle();
  }
  </code></pre>
  
  <p>changeTitle.h:</p>
  
  <pre><code>void changeTitle();
  </code></pre>
  
  <p>changeTitle.cc:</p>
  
  <pre><code>#include "changeTitle.h"
  
  void changeTitle()
  {
      buttons.set_title("new title");
  }
  </code></pre>