Re: Gnome::UI::App with libglademm



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I do it this way: (I have excised a lot of stuff from the following code
for the sake of brevity.)

// here is the class that displays my window.
class BPtest
{
public:
    BPtest(void);
    ~BPtest(void) {if(setup) delete setup;};
    Gtk::Window *win; // main window pointer initialzied from Glade
protected:
    Glib::RefPtr<Gtk::TextBuffer::TagTable> tagtable;
    Gtk::TextView *textview;  // textview widget intialized from Glade
    Glib::RefPtr<Gnome::Glade::Xml> xml;
};

// here is its constructor
BPtest::BPtest(void)
{
#ifndef USE_GLADE_FILE
// this is where I use the file my xmltocsource utility creates
// to initialize the xml object, eliminating the need to read
// the glade file at runtime.
    xml =
Gnome::Glade::Xml::create_from_buffer(bptestxml,strlen(bptestxml)+1);
#else
// Here I use the .glade file so that I can see the result of
// changes made in Glade w/o having to recompile my project.  It is
// for testing only
    xml =
Gnome::Glade::Xml::create("/home/bob/Projects/fiscal/BPtest/bptest.glade");
#endif
	
  // here is where I initialize the widgets for my main app
  // window.
  xml->get_widget("window1",win);   // main window pointer
  xml->get_widget("textview1",textview); // textview widget used to show
	                                 // comms progress with ILUMA

  // command the main window to display all its widget
  // children
  win->show_all_children();
  appIsReady = TRUE;
}

//finally, here is the main function
int main(int argc, char *argv[])
{
   Gtk::Main kit(argc, argv);
	
   BPtest bptest;   // initializing the class
	
// note that I pass the Gtk::Window object created from the glade file
// to Gtk::Main::run here, not the class itself since it is not derived
// from Gtk::Window.
//Shows the window and returns when it is closed.

  if(bptest.appIsReady)
     Gtk::Main::run(*bptest.win);
	
  return 0;
}

Once again, I excised a lot of code from the foregoing for the sake of
brevity.  I hope this helps.

Bob Caryl

Simon Siemens wrote:
> I try to to create a C++-Gnome-application with libglademm. I use the
> following main function:
> 
> 
> int main(int argc, char **argv)
> {
>   Gtk::Main kit(argc, argv);
> 
>   Glib::RefPtr<Gnome::Glade::Xml> refXml;
> 
>   try {
>     refXml = Gnome::Glade::Xml::create("../btperformance.glade");
>   } catch (const Gnome::Glade::XmlError& ex) {
>     std::cerr << ex.what() << std::endl;
>     return 1;
>   }
> 	
>   return 0;
> }
> 
> 
> It compiles well. However when I execute it, there is an error:
> 
> GnomeUI-ERROR **: You must call gnome_program_init() before creating a
> GnomeApp
> aborting...
> Aborted
> 
> 
> What is going wrong? I think, I shouldn't use gnome_program_init,
> because I want to use the ...mm libraries (e.g. gnomemm or gnomeuimm).
> In glade I chose the application type GnomeApp (which might be the C
> type corresponding with Gnome::UI::App).
> 
> Thanks for your help,
> 
> Simon
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFE+HtpuCj6XIbb5UIRAueDAKDJ2uS48j7widnzQHYy2VCe997/XwCdFSyx
cF0V82iM2s7KXQ1ceqdZxaQ=
=+wPp
-----END PGP SIGNATURE-----
begin:vcard
fn:Robert Caryl
n:Caryl;Robert
org:Fiscal Systems, Inc.
adr:;;102 Commerce Circle;Madison;AL;35758;USA
email;internet:bob fis-cal com
title:Senior Software Design Engineer
tel;work:356-772-8920 X108
x-mozilla-html:TRUE
url:http://www.fis-cal.com
version:2.1
end:vcard



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