00001 // Filename: gtkBase.cxx 00002 // Created by: drose (14Jul00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "gtkBase.h" 00020 00021 #include <notify.h> 00022 00023 Gtk::Main *GtkBase::_gtk = NULL; 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: GtkBase::Constructor 00027 // Access: Public 00028 // Description: 00029 //////////////////////////////////////////////////////////////////// 00030 GtkBase:: 00031 GtkBase() { 00032 if (_gtk != (Gtk::Main *)NULL) { 00033 nout << "Invalid attempt to create multiple instances of GtkBase!\n"; 00034 abort(); 00035 } 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: GtkBase::Destructor 00040 // Access: Public 00041 // Description: 00042 //////////////////////////////////////////////////////////////////// 00043 GtkBase:: 00044 ~GtkBase() { 00045 nassertv(_gtk != (Gtk::Main *)NULL); 00046 delete _gtk; 00047 _gtk = NULL; 00048 } 00049 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: GtkBase::parse_command_line 00053 // Access: Public, Virtual 00054 // Description: This is overridden for GtkBase to give Gtk a chance 00055 // to pull out its X-related parameters. 00056 //////////////////////////////////////////////////////////////////// 00057 void GtkBase:: 00058 parse_command_line(int argc, char *argv[]) { 00059 nassertv(_gtk == (Gtk::Main *)NULL); 00060 _gtk = new Gtk::Main(argc, argv); 00061 ProgramBase::parse_command_line(argc, argv); 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: GtkBase::main_loop 00066 // Access: Public 00067 // Description: Call this after all is set up to yield control of the 00068 // main loop to Gtk. This normally doesn't return. 00069 //////////////////////////////////////////////////////////////////// 00070 void GtkBase:: 00071 main_loop() { 00072 nassertv(_gtk != NULL); 00073 00074 _gtk->run(); 00075 } 00076