Re: [gtkmm] project an interface



pallucchini roberto <r palluk virgilio it> writes:

> hi all,
> i'd wish an advice for make a user interface with gtkmm and glade.
> I'm started to write a simple program where i have a main application
> window and some buttons (or menubar) that call 2 forms. Because this
> forms are complex and have a lot of data i need to open it one of time,
> only when are called from the user. Now, i want use glade2 files (xml)
> and gtkmm, i have see what i need to do for manage windows, events and
> mode, but i don't understand what i can do for make the forms structure
> with glade. With the libglademm xml create function i can recall the
> file and attach to the main window, but under glade i need to start to
> write the interface from a gtkWindow!
Yes, but you can call xml->get_widget(...) to get the widget you need.
Another approach is not to write main window by hand, like this:
class Application
{
    Glib::RefPtr<Gnome::Glade::Xml> xml;
public:
    Application();

    Gtk::Window* main_window()
    {
      return get_widget<Gtk::Window>("main_window");
    }
};

Application::Application()
    : xml(Gnome::Glade::Xml::create("app.glade")),
{ 
    connect_signals();
}

void Application::connect_signals()
{
    get_widget<Gtk::MenuItem>("mi_exit")->signal_activate().connect(sigc::mem_fun(*main_window(), &Gtk::Window::hide));
    get_widget<Gtk::MenuItem>("mi_help_about")->signal_activate().connect(sigc::mem_fun(*this, &Application::show_about));
    ...
}

int main()
{
  Gtk::Main kit(&argc, &argv);
  Application app;
  kit.run(*app.main_window());
}

> i hope that you understand me... i'm sorry for my poor english :-)

-- 
WBR, Max Vasin.
        JID: maxvasin jabber ru
        ICQ: 276438891




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]